Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 35

Cs assignment file

Strings

Lists

Tupples

Dictionary

SQL
List Programs
1. WAP where list of integers taken by user and passed as
parameter to function named EvenOdd to double the odd
values and half the even values of the list and display the
List
Program –
1. print("Hello User")
2. def EvenOdd(L1):
3. L2=L1
4. Final = []
5. for i in L2 :
6. if i%2==0:
7. Final.append(i/2)
8. elif i%2!=0:
9. Final.append(2*i)
10. return Final
11. def inlist():
12. X = int(input("Enter number of values to be added in the list :
"))
13. Y = []
14. for i in range (X):
15. print("Enter Element",i+1,": ",end="")
16. R = eval(input())
17. Y.append(R)
18. return Y
19. List = inlist()
20. print(EvenOdd(List))
Output –
Hello User
Enter number of values to be added in the list : 3
Enter Element 1 : 12
Enter Element 2 : 21
Enter Element 3 : 23
[6.0, 42, 46]
2. WAP where list of integers taken by the user and Passing
list to function to calculate sum and average of all numbers
and return it in the form of tuple

Program –
1. def inlist():
2. X = int(input("Enter number of values to be added in the list :
"))
3. Y = []
4. for i in range (X):
5. print("Enter Element",i+1,": ",end="")
6. R = eval(input())
7. Y.append(R)
8. return Y
9. def Sum_Avg(L1):
10. Sum = 0
11. Y = len(L1)
12. for i in L1:
13. Sum += i
14. Avg = Sum/Y
15. Tuple = (Sum,Avg)
16. return Tuple
17.
18. X = inlist()
19. Y = Sum_Avg(X)
20. print("List - ",X,"Tuple = ",Y)

Output –
Enter number of values to be added in the list : 5
Enter Element 1 : 13
Enter Element 2 : 12
Enter Element 3 : 13
Enter Element 4 : 12
Enter Element 5 : 50
List - [13, 12, 13, 12, 50] Tuple = (100, 20.0)
3. WAP where list of integers taken by user and Passing two
parameters list to function and number to be searched in
the list and return the position of element in the list

Program –
1. def inlist():
2. X = int(input("Enter number of values to be added in the list : "))
3. Y = []
4. for i in range (X):
5. print("Enter Element",i+1,": ",end="")
6. R = eval(input())
7. Y.append(R)
8. return Y
9. def Search(L1,X):
10. Postion = L1.index(X)+1
11. return Postion
12. List = inlist()
13. X = int(input("Enter The Element to be searched : "))
14. print("So ",X," is the Element ",Search(List,X),"in the list")

Output –
Enter number of values to be added in the list : 5
Enter Element 1 : 13
Enter Element 2 : 13
Enter Element 3 : 12
Enter Element 4 : 4113
Enter Element 5 : 1
Enter The Element to be searched : 1
So 1 is the Element 5 in the list
4. WAP where list of integers taken by user and Passing two
parameters list to function and number to be counted in the
list and return the number of occurrence of element in the
list.
Program –
1. def inlist():

2. X = int(input("Enter number of values to be added in the list : "))


3. Y = []
4. for i in range (X):
5. print("Enter Element",i+1,": ",end="")
6. R = eval(input())
7. Y.append(R)
8. return Y
9. def Count(L1,X):
10. Count = 0
11. for i in L1:
12. if i == X:
13. Count += 1
14. return Count
15. List = inlist()
16. X = int(input("Enter The Element to be counted : "))
17. print("So ",X," is ",Count(List,X),"times in the list")

Output –
Enter number of values to be added in the list : 5
Enter Element 1 : 12
Enter Element 2 : 13
Enter Element 3 : 23
Enter Element 4 : 23
Enter Element 5 : 23
Enter The Element to be counted : 23
So 23 is 3 times in the list
5. WAP where list of integers taken by user and Passing two
parameters list to function and number to be searched in the list
and return the position of element in the list. Program should be
menu driven.
Program –
1. def inlist():
2. X = int(input("Enter number of values to be added in the list : "))
3. Y = []
4. for i in range (X):
5. print("Enter Element",i+1,": ",end="")
6. R = eval(input())
7. Y.append(R)
8. return Y
9. def Search(L1,X):
10. Postion = L1.index(X)+1
11. return Postion
12. while True:
13. Code = int(input("Enter 1 : For Search \nEnter 2 : For Exit \nEnter Code : "))
14. if Code== 1:
15. List = inlist()
16. X = int(input("Enter The Element to be searched : "))
17. print("So ",X," is the Element ",Search(List,X),"in the list")
18. elif Code ==2:
19. print("Exiting Program...")
20. break
Output –
Enter 1 : For Search
Enter 2 : For Exit
Enter Code : 1
Enter number of values to be added in the list : 4
Enter Element 1 : 1
Enter Element 2 : 2
Enter Element 3 : 3
Enter Element 4 : 4
Enter The Element to be searched : 2
So 2 is the Element 2 in the list
Enter 1 : For Search
Enter 2 : For Exit
Enter Code : 2
Exiting Program...
11. WAP to remove all odd numbers from the given list.
(NOTE – Programs 6 to 10 where same as Program 1-5)
Program –
1. def inlist():
2. X = int(input("Enter number of values to be added in the list :
"))
3. Y = []
4. for i in range (X):
5. print("Enter Element",i+1,": ",end="")
6. R = eval(input())
7. Y.append(R)
8. return Y
9. def DelOdd(L1):
10. L2 = list(L1)
11. for i in L2:
12. if i % 2 != 0:
13. Y = L2.index(i)
14. del L2[Y]
15. return L2
16. L1 = inlist()
17. print(DelOdd(L1))

Output –
Enter number of values to be added in the list : 5
Enter Element 1 : 1
Enter Element 2 : 2
Enter Element 3 : 3
Enter Element 4 : 4
Enter Element 5 : 5
[2, 4]

12. WAP to display the second largest element of a given


list.
Program –

1. def inlist():
2. X = int(input("Enter number of values to be added in the list : "))
3. Y = []
4. for i in range (X):
5. print("Enter Element",i+1,": ",end="")
6. R = eval(input())
7. Y.append(R)
8. return Y
9. def Second_Largest(L1):
10. Z = max(L1)
11. L2 = list(L1)
12. L2.remove(Z)
13. Y = max(L2)
14. return Y
15. L1 = inlist()
16. print("Second Largest Item is :",Second_Largest(L1))

Output –
Enter number of values to be added in the list : 7
Enter Element 1 : 134
Enter Element 2 : 1341
Enter Element 3 : 213
Enter Element 4 : 2133
Enter Element 5 : 1213
Enter Element 6 : 1231
Enter Element 7 : 1341
Second Largest Item is : 1341

13. WAP to display frequencies of all the elements of a list.


Program –
1. def inlist():
2. X = int(input("Enter number of values to be added in the list : "))
3. Y = []
4. for i in range (X):
5. print("Enter Element",i+1,": ",end="")
6. R = eval(input())
7. Y.append(R)
8. return Y
9.
10. def Frequency(L1):
11. L2 = []
12. print("Frequencies - ")
13. for i in L1:
14. if i not in L2:
15. L2.append(i)
16. for i in L2:
17. print(i,":",L1.count(i))
18. print("These are frequencies")
19.
20. L1 = inlist()
21. print(Frequency(L1))
Output –
Enter number of values to be added in the list : 7
Enter Element 1 : 12
Enter Element 2 : 23
Enter Element 3 : 12
Enter Element 4 : 42
Enter Element 5 : 23
Enter Element 6 : 42
Enter Element 7 : 12
Frequencies -
12 : 3
23 : 2
42 : 2
These are frequencies
14. WAP in Python to find and display the sum of all the
values which are ending with 3 from a list.
Program –
1. def inlist():
2. X = int(input("Enter number of values to be added in the list : "))
3. Y = []
4. for i in range (X):
5. print("Enter Element",i+1,": ",end="")
6. R = eval(input())
7. Y.append(R)
8. return Y
9. def Sum_End(L1,X):
10. Sum = 0
11. J = str(X)
12. for i in L1:
13. K = str(i)
14. if K.endswith(J):
15. Sum += i
16. return Sum
17. L1 = inlist()
18. print("Sum of No. ending with 3 : ",Sum_End(L1,3))
Output –
Enter number of values to be added in the list : 5
Enter Element 1 : 12
Enter Element 2 : 123
Enter Element 3 : 1313
Enter Element 4 : 1231
Enter Element 5 : 123
Sum of No. ending with 3 : 1559

Strings Program
1. Write a Python program using function to swap cases of a
given string passed as parameter.
Program –
1. X = input("Enter String : ")
2. print("Swap Case - ",X.swapcase())

Output -
Enter String : Hello World!
Swap Case - hELLO wORLD

2. Write a Python program using function to find largest


word in a given string passed a parameter.
Program –
1. S1 = input("Enter string : ")
2. Y = S1.split()
3. Max = int(0)
4. Max_Word = str()
5. for i in Y:
6.     if len(i) > Max:
7.         Max = len(i)
8.         Max_Word = i
9. print("So the word with maximum length is ",Max_Word,"With
",Max,"characters.")
Output –
Enter string : This is my ultimate Program
So the word with maximum length is ultimate With 8 characters.
3. Write a Python program to count Uppercase, Lowercase,
special character and numeric values in a inputted string by
user and passed as parameter.
Program –
1. S1 = input("Enter string : ")
2. Upper_Case = 0
3. Lower_Case = 0
4. Special = 0
5. Num = 0
6. Space = 0
7. for i in S1:
8. if i.isalpha():
9. if i.isupper():
10. Upper_Case += 1
11. if i.islower():
12. Lower_Case += 1
13. elif i.isdigit():
14. Num +=1
15. elif i.isspace():
16. Space +=1
17. else:
18. Special +=1
19. print("So th frequncy are - ")
20. print("Upper Case : ",Upper_Case)
21. print("Lower Case : ",Lower_Case)
22. print("Number : ",Num)
23. print("Spaces : ",Space)
24. print("Special Character : ",Special)
Output –
Enter string : Rs. 100 in $$ is around 1.1
So th frequncy are -
Upper Case : 1
Lower Case : 11
Number : 5
Spaces : 6
Special Character : 4
4. Write a Python program using function to capitalize first
letters of each word of a given string.
Program –
1. S1 = input("Enter string : ")
2. print(S1.title())
Output –
Enter string : My name is shivansh
My Name Is Shivansh

5. Write a Python program using function to count and


display the vowels of a string entered and passed as
parameter.

Program –
3. def CountVowels(S):
4. Count = 0
5. for i in S:
6. if i in ("a","e","i","o","u"):
7. Count += 1
8. return Count
9.
10. S1 = input("Enter string : ")
11. print(CountVowels(S1))

Output -

Enter string : Hello World


3

6. Write a Python program using function to count no of


words in a string passed as parameter.
Program –
1. def Count(S1):
2.     Y = S1.split()
3.     return len(Y)
4.
5. S1 = input("Enter string : ")
6. print("No. of Words : ",Count(S1))

Output –
Enter string : Hello World
No. of Words : 2

7. Write a Python program using function to count how


many words start with letter 'S' in the string passed as
parameter.
Program –
1. def CountS(S1):
2. Count = 0
3. Y = S1.split()
4. for i in S1:
5. if i.startswith("S"):
6. Count += 1
7. return Count
8.
9. S1 = input("Enter string : ")
10. print("No. of Words starting with S : ",CountS(S1))
Output -
Enter string : Shivansh is here
No. of Words starting with S : 1
8. Write a Python program using function to reverse string.
Program –
1. S1 = input("Enter string : ")
2. print("Reverse String : ",S1[-1::-1])
Output -
Enter string : Hello World
Reverse String : dlroW olleH

9. Write a Python program using function to reverse the


words of the srting passed as parameters.

Program –
1. def Rev(S1):
2. Y = S1.split()
3. k =str()
4. for i in Y:
5. k += i[::-1] + " "
6. return k
7.
8. S1 = input("Enter string : ")
9. print("Reverse String (words) : ",Rev(S1))

Output –
Enter string : Hello World
Reverse String (words) : olleH dlroW

10. Write a Python program using function to take a string


from user, character to be searched and spl char to be
replaced (passed three parameters to the function) and
replace the character with spl char passed and
display the string
Program –
1. def Replace(S1,Old,New):
2. X = str()
3. for i in S1:
4. if i == Old:
5. X += New
6. else:
7. X += i
8. return X
9. S1 = input("Enter string : ")
10. Old = input("Enter Character to be replaced : ")
11. New = input("Enter Character to be placed : ")
12. print(Replace(S1,Old,New))

Output –
Enter string : Cooks are the best
Enter Character to be replaced : C
Enter Character to be placed : B
Books are the best
Dictionary Programs
1. Write a program to input names of in customers and their
details like items bought cost and phone number, store it in
dictionary and display all in a tabular form
Program -
1. def Input():
2. Name = input("Enter your name : ")
3. Mobile_no = input("Enter your Mobil no. : ")
4. Items = input("Enter your Items Bought : ")
5. Total_Cost = input("Enter Total cost of Item in Rs. : ")
6. L1 = [Total_Cost,Name,Items,Mobile_no,]
7. return Name,L1
8. Products = {"Santosh Kasana":["Rs. 300","Pocket Sanitizer",9191919191],"Virendre Singh":
["Rs. 900","Soap and Brush ",8989898989],}
9. X,Y = Input()
10. Products[X] = Y
11. L1 = ["SNO","Name","Total Cost","Items Purchased","Phone No."]
12. print("\n")
13. print(":"*126)
14. print('::',L1[0].center(5),"::",L1[1].center(27),"::",L1[2].center(20),"::",end='')
15. print(L1[3].center(29),"::",L1[4].center(24),"::")
16. print(":"*126)
17. Count = 1
18. for i in Products.keys():
19. print(':: ',Count,' ::\t',i,"\t",end='')
20. for k in Products[i]:
21. print('::\t',k,"\t",end = '')
22. print(' ::')
23. Count+=1
24. print(":"*126)
25. print("")

Output –

2. Write a program to remove duplicate values in the


dictionary.
Program -
1. D1 = {1:20,2:10,3:131,4:11,5:10,6:20,6:20}
2. print(D1)
3. D2 = dict()
4. Y = []
5. for i in D1.keys():
6.     if D1[i] not in Y:
7.         Y.append(D1[i])
8.         D2[i] = D1[i]
9. print(D2)
10. D1 = {1:20,2:10,3:131,4:11,5:10,6:20,6:20}
11. print(D1)
12. D2 = dict()
13. Y = []
14. for i in D1.keys():
15.     if D1[i] not in Y:
16.         Y.append(D1[i])
17.         D2[i] = D1[i]
18. print(D2)
Output –
{1: 20, 2: 10, 3: 131, 4: 11, 5: 10, 6: 20}
{1: 20, 2: 10, 3: 131, 4: 11}

3. WAP that use a dictionary that contains 5 usernames and


password. The program should ask the user to enter their
username and passwords. If user name is not in the
dictionary.the program should indicate that the person is
not a valid user of the system.IF the user name is in the
dictionary.but the user does not enter the right
password,the program should say that the password is
invalid. If the password is correct, then the program should
tell the user that they are now logged into the system..
Program -
1. D1
={"Shivansh":"0wekq#fq23o","Akshat":"11052006","Srishti":"123456
","Parin":"IamPlatipus","Vanshika":"654321"}
2. User_Id = input("Enter Your User ID : ")
3. if User_Id in D1.keys():
4. User_Password = input("Enter the Password :")
5. if User_Password == D1[User_Id]:
6. print("You are now logged in..")
7. else:
8. print("Incorect Password")
9. else:
10. print("User Not in Database")
Output –
Enter Your User ID : shici
User Not in Database
Enter Your User ID : Akshat
Enter the Password :11052006
You are now logged in..

4. Create a dictionary whose keys are month Names and whose


values are the number of days in the corresponding months and
display names of month with 30 days
Program -
1. D1 =
{"Janauary":31,"February":28,"March":31,"April":30,"May":31,"June":30,"July":31,"August":31,"Septe
mber":30,"October":31,"November":30,"Decenmber":31}
2. for i in D1:
3. if D1[i]==30:
4. print(i)

Output –
April
June
September
November
5. Write a program to input names of n employeesname and their
salary and display the name and salary of highest paid employees.
Program -
1. D1={"Ram":100000,"Shaam":200000,"Shyaam":150000}
2. N = int(input("Enter the inputs you want : "))
3. forii in range(N):
4. Name = input("Enter your name : ")
5. Salary = int(input("Enter your salary : "))
6. D1[Name]=Salary
7. K_Max = None
8. V_Max = 0
9. for i in D1:
10. if D1[i]>V_Max:
11. K_Max = i
12. V_Max = D1[i]
13. print(K_Max,"has",V_Max,"salary which is the highest.")
Output –
Enter the inputs you want : 2
Enter your name : Rakhi
Enter your salary : 100000
Enter your name : Vaishali
Enter your salary : 150000
Shaam has 200000 salary which is th highest.
6. WAP to Count the number of times a character appears in
a given string output should like
following Enter a string: HELLO WORLD
H:1
E:1
L:3
O:2
:1
W:1
R:1
D:1
Program -
1. D1 = {}
2. L1 = []
3. X = input("Enter String : ")
4. for i in X:
5. if i not in L1:
6. L1 += i
7. D1[i] = X.count(i)
8. for i in D1:
9. print(i," : ",D1[i])
Output –
Enter String : HELLO WORLD
H : 1
E : 1
L : 3
O : 2
: 1
W : 1
R : 1
D : 1
7. Write a Python script to generate and print a dictionary
that contains a number (between 1 and n) in
the form (x, x*x).
Program -
1. N = int(input("Enter the no. values : "))
2. D1 = {}
3. for i in range(1,N+1):
4. D1[i] = i*i
5. print(D1)

Output –
Enter the no. values : 5
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
Tuples Program
Q1) WAP that creates a tuple storing first 9 items of
Fibonacci Series.
Programs –
1. N=9
2. F=0
3. S=1
4. T1 = (F,S)
5. for i in range (N-2):
6. T=F+S
7. F=S
8. S=T
9. T1 += (T,)
10. print(T1)

Output –
(0, 1, 1, 2, 3, 5, 8, 13, 21)

Q2) WAP that creates a third tuple after adding two tuples.
Add second after first tuple.
Programs –
1. T1 = (1,2,3,4)
2. T2 = (4,5,6,7)
3. T3 = T2+T1
4. print("So Sum of Both tuples is ",T3)

Output –
So Sum of Both tuples is (4, 5, 6, 7, 1, 2, 3, 4)
Q3) WAP to calculate the mean of the numbers of the tuple.
Programs –
1. def Mean(T1):
2. L = len(T1)
3. Sum = 0
4. for i in T1:
5. Sum += i
6. Mean = Sum/L
7. return Mean
8. T1 = (1,3,5)
9. print(Mean(T1))

Output –
3.0

Q4) WAP to calculate the average of the numbers of the


tuple.
Programs –
1. def Avg(T1):
2. L = len(T1)
3. Sum = 0
4. for i in T1:
5. Sum += i
6. Avg = Sum/L
7. return Avg
8. T1 = (1,3,5,4,1,12,321,213)
9. print(Avg(T1))

Output –
70.0
Q5) WAP to combine first 3 elements and last 3 elements
from a tuple
If t1=( 1, 2, 4 ,"a",6,6,8,9,","a",8,9,"y",",7,"L")
Output
( 1, 2, 4 ,"y",7,"L")
Programs –
1. T1 = (1,2,4,"a",6,8,9,"y",7,"L")
2. T2 = T1[0:3]+T1[-3::1]
3. print(T2)

Output –
( 1, 2, 4 ,"y",7,"L")
Module Program
File –
1. print("================== Math Friend ====================")
2. print("\nWelcome to the program of your personal Math Friend")
3. import Module
4. while True :
5. print("\nChoose From The Following - ")
6. print("Press 1 : Quadratic Equation Solver")
7. print("Press 2 : Fatorial Finder")
8. print("Press 3 : Reverse Number")
9. print("Press 4 : Prime Checker")
10. print("Press 0 : Exit")
11. Code = int(input("Enter The Function : "))
12. if (Code == 1):
13. Module.Quadratic()
14. elif (Code == 2):
15. Module.Factorial()
16. elif (Code == 3):
17. Module.Reverse()
18. elif (Code == 4):
19. Module.Prime()
20. elif (Code == 0):
21. break
22. else :
23. print ("Invalid Input")

Module
1. def Quadratic():
2. print("Welcome to Quadratic Equation Solver")
3. A = eval(input("Enter the value of A : "))
4. B = eval(input("Enter the value of B : "))
5. C = eval(input("Enter the value of C : "))
6. D = (B**2)-(4*A*C)
7. if D > 0 :
8. print("The roots of the equation are Distinct and Are Real
Number.")
9. Root_1 = -B+()
10. elif D == 0 :
11. print("The roots of the equation are Equal and Are Real
Number.")
12. elif D < 0 :
13. print("The roots of the equation are Complex Number.")
14. def Prime():
15. print("This Program is to Find if Number is Prime Or Not")
16. X=int(input("Enter The number : "))
17. Factor = 0
18. for i in range (2,(X//2)+1):
19. if (i!=0) and (X%i==0):
20. Factor +=1
21. if (Factor>0):
22. print("The Number is Composite")
23. elif(Factor==0):
24. print("The Number is Prime")
25. else:
26. print("Error")
27. def Reverse ():
28. print("\nThis program is Reverse Number ")
29. X = int(input("Enter The Number : "))
30. A=X
31. B=0
32. while (A!=0):
33. rem = A%10
34. B=B*10+rem
35. A=A//10
36. print("So reverse of The Number ",X," Is ",B)
37. def Factorial():
38. print("This program is to find Factorial of a Number : \n")
39. X=int(input("Enter The Number : "))
40. Factorial = 1
41. for i in range (1,X+1):
42. Factorial *= i
43. print("So, the Factorial of the number is ",Factorial)
Output
================== Math Friend ====================

Welcome to the program of your personal Math Friend

Choose From The Following -


Press 1 : Quadratic Equation Solver
Press 2 : Fatorial Finder
Press 3 : Reverse Number
Press 4 : Prime Checker
Press 0 : Exit
Enter The Function : 1
Welcome to Quadratic Equation Solver
Enter the value of A : 1
Enter the value of B : 2
Enter the value of C : 1
The roots of the equation are Equal and Are Real Number.

Choose From The Following -


Press 1 : Quadratic Equation Solver
Press 2 : Fatorial Finder
Press 3 : Reverse Number
Press 4 : Prime Checker
Press 0 : Exit
Enter The Function : 2
This program is to find Factorial of a Number :

Enter The Number : 12


So, the Factorial of the number is 479001600

Choose From The Following -


Press 1 : Quadratic Equation Solver
Press 2 : Fatorial Finder
Press 3 : Reverse Number
Press 4 : Prime Checker
Press 0 : Exit
Enter The Function : 3

This program is Reverse Number


Enter The Number : 1234
So reverse of The Number 1234 Is 4321

Choose From The Following -


Press 1 : Quadratic Equation Solver
Press 2 : Fatorial Finder
Press 3 : Reverse Number
Press 4 : Prime Checker
Press 0 : Exit
Enter The Function : 4
This Program is to Find if Number is Prime Or Not
Enter The number : 13414
The Number is Composite

SQL Program 1
Create the following tables with the Data Given
SHOPPE and ACCESSORIES
Table SHOPPE
ID SName Area
S001 ABC Computronics CP
S002 All Infotech Media GK II
S003 Tech Shoppe CP
S004 Greeks Tecno Nehru Place
S005 Hitech Tech Store Nehru Place

Table ACCESSORIES
No Name Price ID
A01 Mother Board 1200 S01
A02 Hard Disk 5000 S01
A03 Keyboard 500 S02
A04 Mouse 300 S01
A05 Mother Board 13000 S02
A06 Keyboard 400 S03
A07 LCD 6000 S04
T08 LCD 5500 S05
T09 Mouse 350 S05
T10 Hard Disk 450 S03
Write the SQL Queries
(i) To Display Name and Price of all the ACCESSORIES in the
ascending order of their Price

(ii) To Display ID and SName of all SHOPPE located in Nehru


Place.

(iii) To Display Minimum and Maximum Price of each Name


of accessoories.
(iv) To Display Name,Price of all accessories and their
respective SName where they are available.

(v) Display Name of accessories of more than 5000 price (no


duplicate names)

(vi) Display the no. of suppliers of each area


(vii) Display the total no area available in Shoppe Table

(viii) Display name , Discount which is 5 % price for S002 and


S003.

(ix) Display name , Discount which is 5 % price for S002 and


S003.

(x) To find the average price for hard disk


SQL Program 2
Write the SQL commands for (i),(ii) and (iii) and Outputs for
(iv) and (v)
BOOKS and ISSUES
Table BOOKS
Book_ID BookName AuthorName Publisher Price Qty
L01 Maths Raman ABC 70 20
L02 Science Agarkar DEF 90 15
L03 Social Suresh XYZ 85 30
L04 Computer Sumita ABC 75 7
L05 Telegu Nannayya DEF 60 25
L06 English Wordsworth DEF 55 12

Table ISSUES
Book_ID Qty_Issued
L02 13
L04 5
L05 21
Write the SQL Queries
(i) To show Book Name , Author Name and Price of books
ABC publisher

(ii) To display the details of the Books in descending order


of their price

(iii) To display the Book Id, Book name,


Publisher ,Price ,Qty,Qty_Issued from both the tables woth
their matching Book ID.

(iv) SELECT sum(price) FROM Books WHERE Publisher


=”DEF”;
(v) SELECT Publisher, min(price) FROM Books GROUP BY
Publisher;

You might also like