Professional Documents
Culture Documents
BANGALORE
COMPUTER SCIENCE
PRACTICAL FILE
2023-24
Name: ARNAV GOYAL
Class: 12A
Registration number:
Page 1 of 102
CERTIFICATE OF COMPLETION
This is to certify that Arnav Goyal of class XII A of Sindhi High School,
Date:
Registration No:
Page 2 of 102
ACKNOWLEDGEMENT
I am grateful for all your help, support and guidance in completing this
Date :
Place : Bangalore
Page 3 of 102
INDEX
Page 4 of 102
PYTHON REVISION TOUR – I
Q1) Write a program to print one of the words negative, zero or positive,
according to whether variable x is less than zero, zero or greater than zero,
respectively.
Source Code:
num = float(input("Enter a number: "))
if num > 0:
print("Positive number")
elif num == 0: print("Zero")
else: print("Negative number")
Output:
***
Page 5 of 102
Q2) Write a program that returns True if the input number is an even
number, False otherwise.
Source code:
x = int(input(“Enter a number: “))
if x % 2 == 0:
print(“True”) else: print(“False”)
Output:
***
Q3) Write a python program that calculates and prints the number of
seconds in a year.
Source Code:
days = 365
hours = 24
mins = 60
secs = 60
secsInYear = days * hours * mins * secs
print(“Number of seconds in a year =”, secsInYear)
Output:
Page 6 of 102
***
Q4) Write a python program that accepts two integers from the user and
prints a message saying if first number is divisible by second number or if it
is not.
Source Code:
a = int(input(“Enter first number: “))
b = int(input(“Enter second number: “))
if a % b == 0:
print(a, “is divisible by”, b) else: print(a, “is not divisible by”, b)
Output:
***
Page 7 of 102
Q5) Write a program that asks the user the day number in a year in the
range 2 to 365 and asks the first day of the year — Sunday or Monday or
Tuesday etc. Then the program should display the day on the day-number
that has been input.
Source Code:
dayNames = [”MONDAY”, “TUESDAY”, “WEDNESDAY”, “THURSDAY”,
“FRIDAY”, “SATURDAY”, “SUNDAY”] dayNum = int(input(“Enter day
number: “)) firstDay = input(“First day of year: “)
if dayNum < 2 or dayNum > 365:
print(“Invalid Input”) else: startDayIdx =
dayNames.index(str.upper(firstDay))
currDayIdx = dayNum % 7 + startDayIdx - 1
if currDayIdx >= 7:
currDayIdx = currDayIdx - 7
print(“Day on day number”, dayNum, “:”, dayNames[currDayIdx])
Output:
***
Q6) One foot equals 12 inches. Write a function that accepts a length
written in feet as an argument and returns this length written in inches.
Write a second function that asks the user for a number of feet and returns
this value. Write a third function that accepts a number of inches and
displays this to the screen. Use these three functions to write a program
Page 8 of 102
that asks the user for a number of feet and tells them the corresponding
number of inches.
Source Code:
def feetToInches(lenFeet):
lenInch = lenFeet * 12
return lenInch
def getInput():
len = int(input(“Enter length in feet: “))
return len
def displayLength(l):
print(“Length in inches =”, l) ipLen = getInput() inchLen =
feetToInches(ipLen) displayLength(inchLen)
Output:
***
Q7) Write a program that reads an integer N from the keyboard computes
and displays the sum of the numbers from N to (2 * N) if N is nonnegative. If
N is a negative number, then it's the sum of the numbers from (2 * N) to N.
The starting and ending points are included in the sum.
Source Code:
Page 9 of 102
if n < 0:
sum += i
else:
sum += i
Output:
***
Sample run :
Page 10 of 102
Source Code:
monthIndex = int(dateStr[:2]) - 1
month = months[monthIndex]
day = dateStr[2:4]
year = dateStr[4:]
print(newDateStr)
Output:
***
Q9) Write a program that prints a table on two columns — table that helps
converting miles into kilometres.
Source Code:
print('Miles | Kilometres')
Page 11 of 102
print(1, "\t", 1.60934)
Output:
***
Q10) Write another program printing a table with two columns that helps
convert pounds in kilograms.
Source Code:
print('Pounds | Kilograms')
Page 12 of 102
for i in range(10, 101, 10):
Output:
***
Source code:
def ispalindrome(str1):
for i in range(0,int(len(str1)/2)):
if str1[i]!=str1[len(str1)-i-1]:
return False
Page 13 of 102
return True
s=input("Enter string:")
ans=ispalindrome(s)
if (ans):
print("The given string is palindrome")
else:
print("The given string is not a palindrome")
Output:
Source code:
First=0
Second=1
num= int(input("How many Fibonacci numbers you want to display? "))
if num<0:
print("Please enter a positive integer")
else:
print(First)
print(Second)
for i in range(2,num):
Third-First+Second
Page 14 of 102
First-Second
Second-Third
print(Third)
Output:
Q13) Write a program that reads two times in military format (0900, 1730)
and prints the number of hours and minutes between the two times.
8 hours 30 minutes
Source Code:
Page 15 of 102
ft = input("Please enter the first time : ")
hrs = diff // 60
mins = diff % 60
Output:
***
Page 16 of 102
PYTHON REVISION TOUR – II
Q14) Write a program that prompts for a phone number of 10 digits and two
dashes, with dashes after the area code and the next three numbers. For
example, 017-555-1212 is a legal input. Display if the phone number
entered is valid format or not and display if the phone number is valid or
not (i.e., contains just the digits and dash at specific places.)
Source code:
length = len(phNo)
if length == 12 \
and phNo[:3].isdigit() \
and phNo[4:7].isdigit() \
Page 17 of 102
and phNo[8:].isdigit() :
else :
Output:
***
Q15) Write a program that should prompt the user to type some sentence(s)
followed by "enter". It should then print the original sentence(s) and the
following statistics relating to the sentence(s) :
Number of words
length = len(str)
spaceCount = 0
alnumCount = 0
for ch in str :
if ch.isspace() :
spaceCount += 1
elif ch.isalnum() :
alnumCount += 1
print("Original Sentences:")
print(str)
Output:
Page 19 of 102
***
Q16) Write a program that takes any two lists L and M of the same size and
adds their elements together to form a new list N whose elements are sums
of the corresponding elements in L and M. For instance, if L = [3, 1, 4] and
M = [1, 5, 9], then N should equal [4,6,13].
Source Code:
N = []
for i in range(len(L)):
N.append(L[i] + M[i])
print("List N:")
print(N)
Page 20 of 102
Output:
***
Q17) Write a program rotates the elements of a list so that the element at
the first index moves to the second index, the element in the second index
moves to the third index, etc., and the element in the last index moves to
the first index.
Source Code:
print(l)
l = l[-1:] + l[:-1]
print("Rotated List")
print(l)
Output:
Page 21 of 102
***
Q18) Write a program to input a line of text and print the biggest word
(length wise) from it.
Source Code:
words = str.split()
longWord = ''
for w in words :
longWord = w
Output:
Page 22 of 102
***
Q19) Write a program that creates a list of all integers less then 100 that
are multiples of 3 or 5.
Source Code:
lst = [ ]
if i % 3 == 0 or i % 5 == 0 :
lst += [ i ]
print (lst)
Output:
Page 23 of 102
***
Q20) Define two variables first and second show that first = "jimmy" and
second = "johny". Write a short python code segment that swaps the values
assigned to these two variable and print the results.
Source Code:
second= "johny"
Output:
***
Page 24 of 102
Q21) Write python that create a tuple storing first 9 term of Fibonacci
series.
Source Code:
fib = (0,1,1)
for i in range(6):
print(fib)
Output:
***
Source code:
import random
guess=True
while guess:
n=random.randint(1.6)
if userinput==n:
Page 25 of 102
else:
if val==’y’ or val==’Y’:
guess=True
else:
guess=False
Output:
Source Code:
def adddict(dict1,dict2) :
dic = {}
for i in dict1 :
Page 26 of 102
dic [ i ] = dict1 [i]
for j in dict2 :
dic [ j ] = dict2 [ j ]
return dic
print(adddict(dict1,dict2))
Output:
***
Q24) Write a program to sort a dictionary’s keys using bubble sort and
produce the sorted keys as a list.
Source Code:
key = list(dic.keys())
Page 27 of 102
if key [ i ] > key [ i + 1 ] :
print(key)
Output:
***
Q25) Write a program to sort a dictionary’s value using bubble sort and
produce the sorted values as a list.
Source Code:
val = list(dic.values())
print(val)
Output:
Page 28 of 102
***
Source code:
def circle(r):
Area 3.14*(r**2)
print("The Area of circle is:",Area)
def Rectangle(L,B):
R=L*B
print("The Area of rectangle is:",R)
def Triangle(B,H):
R=0.5*B*H
print("The Area of triangle is:",R)
print("1.Area of circle")
print("2.Area of Rectangle")
print("3.Area of Triangle")
ch=int(input("Enter your choice:"))
if ch==1:
a=float(input("Enter the radius value:"))
circle(a)
Page 29 of 102
elif ch==2:
L=float(input("Enter the length of rectangle:"))
B=float(input("Enter the breath of rectangle:"))
Rectangle(L,B)
elif ch==3:
B=float(input("Enter the Base of Triangle:"))
H=float(input("Enter the Height of Triangle:"))
Triangle(B,H)
else:
print("Invalid option")
Output:
Page 30 of 102
Q27) Write a menu driven program to perform arithmetic operations.
Page 31 of 102
Source code:
print("1.Addition")
print("2.Subtraction")
print("3.Multiplication")
print("4.Division")
opt=int(input("Enter your choice:"}}
a=int(input("Enter the 1st Number:"))
b=int(input("Enter the 2st Number:"))
if opt==1:
c=a+b
print("The Addition of 2 number is:",c)
elif opt==2:
c-a-b
print("The Subtraction of 2 number is:",c)
elif opt==3:
c=a*b
print("The Multiplication of 2 number is:",c)
elif opt==4:
if b==0:
print("Enter any other number other than zero:"}
else:
c=a/b
print("The Division of 2 number is:",c)
else:
print("Invalid option")
Output:
Page 32 of 102
Page 33 of 102
WORKING WITH FUNCTIONS
Source Code:
rup(doll) #void
print("( non void ) rupees in ",doll ,"dollar = ", rupee(doll) ) # non Void
Output:
***
Page 34 of 102
Q29) Write a function to calculate volume of a box with appropriate default
values for its parameters.
Your function should have the following input parameters:
(a) length of box ;
(b) width of box ;
(c) height of box.
Test it by writing complete program to invoke it.
Source Code:
def vol( l = 1, w = 1 , h = 1 ) :
return l * w * h
Output:
***
Page 35 of 102
Q30) Write a program to have following functions :
(i) A function that takes a number as argument and calculates cube for it.
The function does not return a value. If there is no value passed to the
function in function call, the function should calculate cube of 2.
(ii) A function that takes two char arguments and returns True if both the
arguments are equal otherwise False.
Test both these functions by giving appropriate function call statements.
Source Code:
def cube( a = 2 ) :
print( "Cube of ", a ,"=" , a ** 3 )
if num == "" :
cube()
else :
cube( int (num) )
def chr(char1,char2) :
if char1 == char2 :
return "True"
else:
return"False "
Page 36 of 102
Output:
***
Source Code:
import random
def ran(a , b) :
print( random . randint(a , b ) )
ran(first , second )
ran(first , second )
ran(first , second )
Page 37 of 102
Output:
***
Q32) Write a function that receives two string arguments and checks
whether they are same-length strings (returns True in this case otherwise
false).
Source Code:
def chr(a , b) :
print( len(a ) == len(b) )
Output:
***
Page 38 of 102
Q33) Write a function namely nthRoot () that receives two parameters x and
n and returns nth root of x i.e., X**1/n . The default value of n is 2.
Source Code:
def root(x , n = 2 ) :
print( x ** (1 / n) )
if n == 0 :
root( x)
else :
root(x,n)
Output:
***
Page 39 of 102
Q34) Write a function that takes a number n and then returns a randomly
generated number having exactly n digits (not starting with zero)
Source Code:
import random
def ran( x ) :
a = 10 ** (x - 1 )
b= 10 ** (x )
print( random.randint ( a , b ) )
ran(n)
Output :-
***
Page 40 of 102
Q35) Write a function that takes two numbers and returns the number that
has minimum one's digit.
Source Code:
def min(x , y ) :
a = x % 10
b = y % 10
if a < b :
return x
else :
return y
Output:
***
Page 41 of 102
Q36) Write a program that generates a series using a function which takes
first and last values of the series and then generates four terms that are
equidistant e.g., if two numbers passed are 1 and 7 then function returns 1
3 5 7.
Source Code:
ser(first , last )
Output:
***
Page 42 of 102
FILE HANDLING
Q37) Write a program that reads a text file and creates another file that is
identical except that every sequence of consecutive blank spaces is replaced
by a single space.
Source Code:
file1 = open("portal.txt","r")
file2 = open("Express.txt","w")
lst = file1.readlines()
for i in lst :
word = i.split()
for j in word :
file2.write( j + " ")
file2.write("\n")
file2.close()
file1.close()
Page 43 of 102
Output:
***
Source Code:
import pickle
def portal( ) :
file1 = open("sports.dat","rb")
file2 = open("Athletics.dat","wb")
try :
while True :
File sports.dat:
File Athletics.dat:
Page 45 of 102
Arvind 7258031
Sachin 7259197
The names contain only one word the names and telephone numbers are
separated by white spaces Write program to read a file and display its
contents in two columns.
print("Name\t|\tPhone no. ")
Source Code:
for i in lst :
data = i.split()
print( data[0] ,end = "\t" )
print("|" , end = "\t")
print ( data[1] )
file.close()
Output:
***
Page 46 of 102
Q40) Write a program to count the words "to" and "the" present in a text file
"Poem.txt".
Source Code:
to_no = 0
the_no = 0
for i in lst :
word = i.split()
for j in word :
if j == "to" or j == "To" :
to_no += 1
elif j == "the" or j == "The" :
the_no += 1
file.close()
Page 47 of 102
Poem.txt contains:
Output:
Page 48 of 102
Q41) A binary file "Book.dat" has structure [BookNo, Book Name, Author,
Price].
(i) Write a user defined function CreateFile() to input data for a record and
add to Book.dat.
(ii) Write a function CountRec(Author) in Python which accepts the Author
name as a parameter and count and return number of books by the given
Author are stored in the binary file "Book.dat".
Source Code:
import pickle
def CreateFile():
f = open("Book.dat", "wb")
while True :
num = int(input("Enter Book Number :- "))
name = input ("Enter Book Name :- ")
aut = input("Enter Author :- ")
pri = float(input("Enter Price of Book :- "))
lst= [ num, name, aut, pri]
pickle.dump( lst, f)
choice = input("For exit (Enter exit):- ")
print()
if choice == "exit" or choice == "Exit":
print("Thank you")
print()
break
f.close()
def CoutRec(aut):
Page 49 of 102
f = open("Book.dat", "rb")
count = 0
try :
while True:
data = pickle.load(f)
if data[2] == aut :
count += 1
except EOFError:
f.close()
print("Number of Book with Author name", aut , "=", count)
CreateFile()
print("For Searching -")
Output:
Page 50 of 102
Q42) Write a program that counts the number of characters up to the first $
in a text file.
Source Code:
file = open("Ishika.txt","r")
data = file.read()
for i in range( len( data ) ):
if data [ i ] == "$" :
break
Output:
***
Page 51 of 102
Q43) Write a function that reads a csv file and creates another csv file with
the same content, but with a different delimiter.
Source Code:
import csv
data = csv.reader(file1)
for i in data :
if i[0][:5] != "check" :
File_write.writerow( i )
file2.close()
Page 52 of 102
Q44) Write a Python program to write a nested Python list to a csv file in
one go. After writing the CSV read the CSV file and display the content
Source Code:
import csv
Output:
***
Page 53 of 102
DATA STRUCTURES [STACKS]
Q45) Write a program that depending upon user's choice, either pushes or
pops an element in a stack.
Source Code:
stack = [ ]
while True :
com = input("Enter ( Push or Pop ) : ")
elif len(stack) == 0 :
print("Underflow")
Output:
Page 54 of 102
***
Source Code:
def POP(Arr):
Arr.pop()
return Arr
Stack=[4,5,6,7]
POP(Stack)
print("Now our stack = ",Stack)
Output:
Page 55 of 102
***
Q47) Write a program that depending upon user's choice, either pushes or
pops an element in a stack the elements are shifted towards right so that
top always remains at 0th (zero) index.
Source Code:
stack = [ ]
while True :
com = input("Enter ( Push or Pop ) : ")
elif len(stack) == 0 :
print("Underflow")
Page 56 of 102
if yes == "No" or yes == "no":
print("Thank you !!!!")
break
Output:
***
Page 57 of 102
Q48) Write a program that depending upon user's choice, either pushes or
pops an element in a stack the elements are shifted towards right so that
top always remains at 0th (zero) index.
Source Code:
stack = [ ]
while True :
com = input("Enter ( Push or Pop ) : ")
elif len(stack) == 0 :
print("Underflow")
Page 58 of 102
Output:
***
Page 59 of 102
DATABASE QUERY W/ SQL
Q49) Create a student table with the student id, name, and marks as
attributes where the student id is the primary key.
***
***
Page 60 of 102
Q51) Delete the details of a particular student from the table ‘student’
whose name is ‘rahul’.
***
Q52) Use the select query to get the details of the customers from the table
order details.
***
Page 61 of 102
Q53) Find the min, max, sum, and average of the marks from student table.
***
Q54) Use the select query to get the details of the students with marks more
than 80.
***
Page 62 of 102
Q55) Write a SQL query to order (student id, marks) table in descending
order of the marks.
***
Q56) Create a new table (order id, customer name, and order date ) by
joining two tables (order id, customer id , and order date) and (customer id ,
customer name).
***
Page 63 of 102
Q57) Find the total number of customers from the table (customer id,
customer name) using group by clause.
***
***
Page 64 of 102
Q60) Write a query to display name of the month for date 01-05-2020
Employee table
***
Q61) Write a SQL query to display the sum of salary of all the employees
present in employee table.
Page 65 of 102
Select SUM (salary) from employee;
***
Q62) Write a SQL query to display the sum of salary of all the employees
present in employee table where the dept = sales
***
Q63) Write a SQL query to display the average of the salary column in
employee table.
Page 66 of 102
Select AVG (salary) from employee
***
Q64) Write a SQL query to display the average of the salary column where
dept = sales
***
Q65) Write a SQL query to display the maximum of the salary column in
employee tables
Page 67 of 102
***
Q66) Write a SQL query to display the maximum of the salary column in the
employee table where dept = sales
***
Q67) Write a SQL query to display the minimum of the salary column in the
employee table.
Q68) Write a SQL query to display the number of rows present in the
employee table.
***
Q69) Write a SQL query to display the number of rows present in the salary
column of the employee table.
Page 69 of 102
***
Q70) Write a SQL query to display the details of depid ,sum of salary and
group by depid from emp1
***
Q71) Write a SQL query to display empid, empname, salary from emp1table
and order by empname
Page 70 of 102
SELECT empid, empname, salary FROM emp1 ORDER BY empname DESC;
***
Q72) Write a SQL query to display the details of depid and count of
employees from emp1
Page 71 of 102
***
Q73) Write a SQL query to display the details of depid, count of employees,
sum(salary) from emp1and group by deptid
***
Q74) Using select show the details of Emp1 table and perform the order by
clause functions
Page 72 of 102
***
Q75) Write a SQL query to display the details of depid and count of
employees from emp1 and group by deptid having count(*)>3
Page 73 of 102
ORDERS TABLES
***
Q76) Write an SQL query to display the names of the customer name
ordered by customer name.
Page 74 of 102
***
Q77) Write an SQL query to display the dates of the orders ordered by order
date.
Page 75 of 102
***
***
Page 76 of 102
***
***
Q81) Write a SQL command to display city, sum(order total) ’revenue’ from
orders table and group by city
Page 77 of 102
***
Q82) Write a SQL command to display city, min(order_total),
max(order_total) from orders table and group by city
SELECT city, min(order_total) ,max(order_total) FROM orders GROUP BY
city;
***
Q83) Write a query to convert and display string ‘large’ into uppercase.
Page 78 of 102
***
Q84) Write a query to remove leading and trailing spaces from string ‘Bar
One’
***
Q85) Display names ‘MR. OBAMA’ and ‘MS. Gandhi’ into lowercase
Page 79 of 102
***
SQL database1 :
Page 80 of 102
1. select * from students;
2. desc students
Page 81 of 102
4. Select * from student order by avg_marks desc
Page 82 of 102
5. Select name, stream from student where name=’Mohan’;
Page 83 of 102
SQL Database 2:
1. desc empl
Page 84 of 102
3. select empno, ename from empl;
Page 85 of 102
5. Select ename, sal, deptno from empl where comm is Nul
6. Select empo, ename, sal, sal*12 from empl where comm IS Null;
Page 86 of 102
7. Select deptno from empl;
Page 87 of 102
8. select distinct deptno from empl;
Page 88 of 102
10. Select * from empl where sal*12 between 25000 and 40000
Page 89 of 102
12. select * from empl where comm > sal;
Page 90 of 102
15. select ename from empl where ename like
Page 91 of 102
PYTHON AND SQL INTERFACE
="12A" )
cursor = db1.cursor()
cursor.execute(sql)
try:
cursor.execute(sql)
db1.commit()
except:
db1.rollback()
db1.close()
Page 92 of 102
Page 93 of 102
2. To create a program to integrate MYSQL with python to display
the details of the employees
import mysql.connector as
mysql db1=
mysql.connect(host="localhost",user="root",passwd='arnav',datab
ase='12A ')
cursor= db1.cursor()
cursor.execute("select * from
emps") print("Data of table emps
displayed") for i in
cursor.fetchmany(3):
print(i)
Page 94 of 102
3. To create a program to integrate MYSQL with python to update
and delete the records in the table
#CONNECTION CHECK
import sys
import mysql.connector as ms
mycon-ms.connect(host="localhost",user="root",passwd="root",d
atabase="class12")
if mycon.is_connected():
print("success")
mycon.close()
Page 95 of 102
OUTPUT:
Success
import sys
import mysql.connector as mis
con=ms.connect(host="localhost",user="learner",
passwd="fast",dat
abase="student")
cur con.cursor()
cur.execute("select * from emp')
data=cur.fetchmany(3)
print(data) connection.close()
OUTPUT:
1876: Jack: 12: A: PCMB: jackclass12@gmail.com: 9876567812:
200
1897: Jill: 12: B: PCMB: jillclass12@gmail.com: 8907865343:
200 1857: Sam: 12:8: PCMB: samclass12@gmail.com :
8907865373:
200
Page 96 of 102
6. WAP TO RETRIVE ALL DATA USING FETCHALL
import sys
import mysql.connector as ms
con=ms.connect(host="localhost",user="root",passwd="root",data
b
ase='class12")
curecon.cursor()
n-intlinput("enter salary:"}]
cur.execute("select * from emp where sal >[sal} and deptno
(deptno)".format(salan,deptno=a)}
data=cur.fetchall()
rec cur.rowcount
if data ! None:
print("data,sep="")
else:
print("no records")
OUTPUT:
enter empo 12
enter dept no 10
(Decimal('7782'), 'clark', 'manager', Decimal(7839"),
datetime.date(1981, 6, 9), Decimal('4450.00'), None,
Decimal('10')): (Decimal(7839'), 'king', 'president', None,
datetime.date(1981, 11, 17), Decimal(7000.00'), None,
Page 97 of 102
Decimal('10'))
import sys
import mysql.connector as ms
con=ms.connect(host="localhost", user="root",passwd="root",
datab
ase="class12")
cur=con.cursor()
n=int(input("enter empo"))
a=int(input("enter dept no"))
cur.execute("select * from emp where sal >[sal) and deptno
(deptno)".format(salen,deptno=a)}
data=cur.fetchall()
rec cur.rowcount
if data ! None:
print("data,sep=":")
else:
print("no records")
OUTPUT:
enter empo 12
enter dept no 10
(Decimal('7782'), 'clark', 'manager', Decimal('7839"),
datetime.date(1981, 6, 9), Decimal('4450.00'), None,
Decimal('10")): (Decimal(7839'), 'king', 'president', None,
Page 98 of 102
datetime.date(1981, 11, 17), Decimal(7000.00'), None,
Decimal('10'))
8. WAP TO RETRIVE DATA USING STRING TEMPLATE
import sys
import mysql.connector as ms
con=ms.connect(host
ase="class12")
"localhost",user="root",passwd="root", datab
cur=con.cursor()
sal<%s %300,4000))
data-cur.fetchall)
for i in data:
print(*)
Page 99 of 102
OUTPUT:
import sys
import mysql.connector as ms
con=ms.connect(host "localhost",user="root",passwd="root",
datab
ase="class12")
cur=con.cursor()
cur.execute("select from emp where sal<l) and
job=(.format(2000,"clerk"})
data=cur.fetchall()
for i in data:
print(i)
OUTPUT:
import sys
Import mysql.connector as ms
conems.connect(host="localhost",user="root",passwd="root",datab
ase="class12")
cur-con.cursor()
data-cur.fetchall()
print(d)
OUTPUT:
SQL QUERIES
14