Read and download free pdf of CBSE Class 12 Computer Science Interface Python with SQL Assignment. Get printable school Assignments for Class 12 Computer Science. Class 12 students should practise questions and answers given here for Interface Python with SQL Computer Science in Class 12 which will help them to strengthen their understanding of all important topics. Students should also download free pdf of Printable Worksheets for Class 12 Computer Science prepared as per the latest books and syllabus issued by NCERT, CBSE, KVS and do problems daily to score better marks in tests and examinations
Assignment for Class 12 Computer Science Interface Python with SQL
Class 12 Computer Science students should refer to the following printable assignment in Pdf for Interface Python with SQL in Class 12. This test paper with questions and answers for Class 12 Computer Science will be very useful for exams and help you to score good marks
Interface Python with SQL Class 12 Computer Science Assignment
Short Answer Type Questions :
Question. Given below is a table Item in database Inventory.
Riya created this table but forget to add column ManufacturingDate. Can she add this column after creation of table? If yes, write the code where user’s name and password are system and test respectively.
Answer: Yes, she can add new column after creation of table.
import mysql.connector
mycon = mysql.connector.connect(
host = “localhost”,
user = “system”,
passwd = “test”,
database = “Inventory”)
cursor = mycon.cursor ( )
cursor.execute (“ALTER TABLE Item ADD
ManufacturingDate Date
NOT NULL”)
mycon.close ( )
Question. Consider the table Faculty whose columns’ name are
F_ID, Fname, Lname, Hire_date, Salary,
Course_name
Write the code to insert the following record into the above table.
Answer: import mysql.connector
mycon = mysql.connector.connect
(host = “localhost”,
user = “root”, passwd = “system”,
database = “Test”)
cursor = con.cursor ( )
sql = “INSERT INTO Faculty (F_ID, Fname,
Lname, Hire_date, Salary,
Course_Name) VALUES
(%s, %s, %s, %s, %s, %s)”
val = [(101, ‘Riya’, ‘Sharma’,
‘12-10-2004’, 35000, ‘Java
Advance’), (102, ‘Kiyaan’,
‘Mishra’, ‘3-12-2010’, 28000,
‘Data Structure’)]
try:
cursor.executemany (sql, val)
mycon.commit ( )
except :
mycon.rollback ( )
mycon.close ( )
Question. Consider the table Persons whose fields are P_ID, LastName, FirstName, Address, City. Write a Python code to add a new row but add data only in the P_Id, LastName and columns as 5, Peterson, Kari respectively.
Answer: import mysql.connector
con = mysql.connector.connect
(host = “localhost”,
user = “admin”,
passwd = “admin@123”,
database = “system”)
cursor = con.cursor ( )
sql= “INSERT INTO Persons (P_ID, LastName,
FirstName) VALUES
(5, ‘Peterson’, ‘Kari’)”
try:
cursor.execute (sql)
con.commit ( )
except:
con.rollback ( )
con.close ( )
Question. Write the code to create a table Product in database Inventory with following fields :
Answer: import mysql.connector
mycon = mysql.connector.connect
(host = “localhost”, user = “system”,
passwd = “hello”,
database = “Inventory”)
cur = mycon.cursor ( )
db = cur.execute (“CREATE TABLE Production
(PID varchar (5) Primary key,
PName char (30),
Price float,
Rank varchar(2)))”
mycon.close( )
Question. Consider the table MobileStock with following fields M_Id, M_Name, M_Qty, M_Supplier
Write the Python code to fetch all records with fields M_Id, M_Name and M_Supplier from database Mobile.
Answer: import mysql.connector as mydb
mycon = mydb.connect (host = “localhost”,
user = “root”, passwd = “system”,
database = “Mobile”)
cursor = mycon.cursor ( )
sql = “SELECT M_Id, M_Name, M_Supplier
FROM MobileStock”
try:
cursor. execute (sql)
display = cursor. fetchall ()
for i in display:
print (i)
except :
mycon.rollback ( )
mycon.close ( )
Question. The table Company of database connect contains the following records
What will be the output of following code?
import mysql.connector
con = mysql.connector.connect
(host = “localhost”,
user = “system”,
passwd = “hello”,
database = “connect”)
cur = con.cursor()
cur.execute (“select Name,
Salary from Company”)
display = cur.fetchone()
print(display)
Answer: (‘ABC’, 35000)
Question. Consider the table Student whose fields are SCODE Name Age strcde Points Grade
Write the Python code to update grade to ‘A’ for all these students who are getting more than 8 as points.
Answer: import mysql.connector as mydb
con = mydb.connect (host = “localhost”,
user = “Admin”,
passwd = “Admin@123”,
database = “system”)
cursor = con.cursor ( )
sql = “UPDATE Student SET Grade = ‘A’
WHERE Points > 8”
try :
cursor. execute (sql)
con.commit ( )
except :
con.rollback ( )
con.close ( )
Question. Write the code to create the connection in which database’s name is Python, name of host, user and password can taken by user. Also, print that connection.
Answer: import mysql.connector
mycon = mysql.connector.connect(
host = “localhost”,
user = “test”,
passwd = “testData”,
database = “Python”)
print(mycon)
Question. Consider the following table Traders with following fields
Write Python code to display the names of those traders who are either from Delhi or from Mumbai.
Answer: import mysql. connector
mycon = mysql.connector.connect
(host = “localhost”, user = “root”,
passwd = “system”,
database = “Admin”)
cursor = mycon. cursor ( )
sql = “SELECT * FROM Traders WHERE
City = ‘Mumbai’ OR City = ‘Delhi’”
try:
cursor.execute(sql)
dis = cursor.fetchall ( )
for i in disp:
print (i)
except :
mycon.rollback ( )
mycon.close ( )
Question. Which data will get added in table Company by following code?
import mysql.connector
con = mysql.connector.connect (
host = “localhost”,
user = “system”,
passwd = “hello”,
database = “connect”)
cur = con.cursor ( )
sql = “insert into Company
(Name, Dept, Salary)
values (%s, %s, %s)”
val = (“ABC”, “DBA”, 35000)
cur.execute (sql, val)
con.commit ( )
Answer: “ABC”, “DBA”, 35000
Question. Consider the following table structure
Faculty with fields as
F_ID(P)
Fname
Lname
Hire_date
Salary
Write the Python code to create the above table.
Answer: import mysql.connector
mycon = mysql. connector.connect (
host = “localhost”,
user = “root”,
passwd = “system”,
database = “School”)
cursor = mycon.cursor ( )
db = cursor.execute (“CREATE TABLE
Faculty (
F_ID varchar (3) Primary key,
Fname varchar (30) NOT NULL,
Lname varchar (40),
Hire_date Date,
Salary Float))
mycon.close ( )
Question. Write the code to create the following table Student with the following fields
RollNo
FirstName
LastName
Address
ContactNo
Marks
Course
Rank
In the table, Rank should be Good, Best, Bad, Worst, Average.
Answer: import mysql.connector
mycon = mysql.connector.connect (
host = “localhost”,
user = “root”,
passwd = “system”,
database = “School”)
cursor = mycon.cursor ( )
db = cursor.execute
(“CREATE TABLE Student(
RollNo Int(5) Primary key,
FirstName varchar(30) NOT NULL,
LastName varchar(30),
Address varchar(50),
ContactNo varchar(20),
Marks Float,
Course char(20),
Rank char(10) check (Rank IN(‘Good’, ‘Best’, ‘Bad’, ‘Worst’, ‘Average’))))
mycon.close ( )
Long Answer Type Questions :
Question. Consider the table MobileMaster
Write the Python code for the following
(i) To display details of those mobiles whose price is greater than 8000.
(ii) To increase the price of mobile Samsung by 2000.
Answer: (i) import mysql.connector as mydb
mycon = mydb.connect
(host = “localhost”,
user = “root”,
passwd = “system”,
database = “Admin”)
cursor = mycon.cursor ( )
sql = “SELECT * FROM MobileMaster
WHERE M_Price > 8000”
try:
cursor.execute (sql)
display = cursor. fetchall ( )
for i in display:
print(i)
except:
mycon.rollback ( )
mycon.close ( )
(ii) import mysql.connector as mydb
mycon = mydb.connect
(host = “localhost”,
user = “root”,
passwd = “system”,
database = “Admin”)
cursor = mycon.cursor ( )
sql = “UPDATE MobileMaster SET M_Price
= M_Price + 2000
WHERE M_Company = ‘Samsung’”
try:
cursor.execute (sql)
mycon.commit ( )
except :
mycon.rollback ( )
mycon.close( )
Question. Create following table using Python code where
Database — Test
Table — Watches
User name — Root
Password — System
Answer: import mysql.connector
my = mysql.connector.connect
(host = “localhost”,
user = “Root”, passwd = “System”,
database = “Test”)
cursor = my.cursor ( )
db = cursor.execute (“CREATE TABLE Watches
(Watch_Id varchar(5) Primary Key,
WatchName char(20) NOT NULL,
Price float,
Type varchar (20),
Qty_store Int(5) NOT NULL))”
sql = “INSERT INTO Watches
(WatchId, WatchName, Price, Type,
Qty_store) VALUES (%s, %s, %s,
%s, %s)”
val = [(“W001”, “High Time”, 10000,
“Unisex”, 100),
(“W002”, “Life Time”, 15000,
“Ladies”, 150),
(“W003”, “Wave”, 20000,
“Gents”, 200),
(“W004”, “HighFashion”, 7000,
“Unisex”, 250),
(“W005”, “Golden Time“, 25000,
“Gents”, 100)]
try:
cursor. executemany (sql, val)
my.commit ( )
except :
my.rollback ( )
my.close ( )
Question. Write the Python code for (i) and (ii) on the basis of table College.
(i) To insert a new row in the table College with the following data
15, “Atin”, 27, “Physics”, “15/05/02”, 8500, “M”
(ii) To delete a row from table in which name is Viren.
Answer: (i) import mysql.connector as mydb
con = mydb.connect (
host = “localhost”,
user = “root”,
passwd = “admin@123”,
database = “Management”)
cursor = con.cursor ( )
sql = “INSERT INTO College (No, Name,
Age, Department, DateofJoin,
Basic, Sex) VALUES
(15, ‘Atin’, 27, ‘Physics’,
‘15/05/02’, 8500, ‘M’)”
cursor.execute (sql)
con.close ( )
(ii) import mysql.connector as mydb
con = mydb.connect
(host = “localhost”,
user = “root”,
passwd = “admin@123”,
database = “Management”)
cursor = con.cursor ( )
try:
cursor.execute (DELETE FROM College
WHERE Name = “Viren” ” )
con.commit ( )
except :
con.rollback ( )
con.close ( )
Question. Here is a table Club
Write the Python code for the following
(i) Update the Address of member whose MemberId is M003 with Noida.
(ii) Delete the record of those member whose name is Sachin.
Answer: (i) import mysql.connector
mycon = mysql.connector.connect
(host = “localhost”,
user = “Admin”, passwd = “Admin@123”, database
= “System”)
cursor = mycon.cursor ( )
try:
cursor.execute (“UPDATE Club SET
Address = “Noida” WHERE MemberId
= “M003”)”)
mycon.commit ( )
except :
mycon.rollback ( )
mycon.close ( )
(ii) import mysql. connector
mycon = mysql. connector.connect
(host = “localhost”,
user = “Admin”,
passwd = “Admin@123”,
database = “System”)
cursor = mycon.cursor ( )
try:
cursor.execute (“DELETE FROM Club
WHERE MemberName = ‘Sachin’)”
cursor.commit ( )
except:
mycon.rollback ( )
mycon.close ( )
CBSE Class 12 Computer Science Computer network Assignment |
CBSE Class 12 Computer Science Communication And Network Concepts Notes |
CBSE Class 12 Computer Science Interface Python with SQL Assignment
We hope you liked the above assignment for Interface Python with SQL which has been designed as per the latest syllabus for Class 12 Computer Science released by CBSE. Students of Class 12 should download and practice the above Assignments for Class 12 Computer Science regularly. We have provided all types of questions like MCQs, short answer questions, objective questions and long answer questions in the Class 12 Computer Science practice sheet in Pdf. All questions have been designed for Computer Science by looking into the pattern of problems asked in previous year examinations. You can download all Revision notes for Class 12 Computer Science also absolutely free of cost. Lot of MCQ questions for Class 12 Computer Science have also been given in the worksheets and assignments for regular use. All study material for Class 12 Computer Science students have been given on studiestoday. We have also provided lot of Worksheets for Class 12 Computer Science which you can use to further make your self stronger in Computer Science.
What are benefits of doing Assignment for CBSE Class 12 Computer Science Interface Python with SQL?
a. Score higher marks: Regular practice of Computer Science Class 12 Assignments for chapter Interface Python with SQL will help to improve understanding and help in solving exam questions correctly.
b. As per CBSE pattern: All questions given above follow the latest Class 12 Computer Science Sample Papers so that students can prepare as per latest exam pattern.
c. Understand different question types: These assignments include MCQ Questions for Class 12 Computer Science with answers relating to Interface Python with SQL, short answers, long answers, and also case studies.
d. Improve time management: Daily solving questions from Interface Python with SQL within a set time will improve your speed and accuracy.
e. Boost confidence: Practicing multiple assignments and Class 12 Computer Science mock tests for Interface Python with SQL reduces exam stress.
How to Solve CBSE Class 12 Computer Science Interface Python with SQL Assignment effectively?
a. Start with Class 12 NCERT and syllabus topics: Always read the chapter carefully before attempting Assignment questions for Class 12 Computer Science Interface Python with SQL.
b. Solve without checking answers: You should first attempt the assignment questions on Interface Python with SQL yourself and then compare with provided solutions.
c. Use Class 12 worksheets and revision notes: Refer to NCERT Class 12 Computer Science worksheets, sample papers, and mock tests for extra practice.
d. Revise tricky topics: Focus on difficult concepts by solving Class 12 Computer Science MCQ Test.
e. Maintain notebook: Note down mistakes in Interface Python with SQL assignment and read them in Revision notes for Class 12 Computer Science
How to practice CBSE Class 12 Computer Science Interface Python with SQL Assignment for best results?
a. Solve assignments daily: Regular practice of Interface Python with SQL questions will strengthen problem solving skills.
b.Use Class 12 study materials: Combine NCERT book for Class 12 Computer Science, mock tests, sample papers, and worksheets to get a complete preparation experience.
c. Set a timer: Practicing Class 12 Computer Science Interface Python with SQL assignment under timed conditions improves speed and accuracy.
You can download free Pdf assignments for CBSE Class 12 Computer Science Interface Python with SQL from StudiesToday.com
All topics given in Interface Python with SQL Computer Science Class 12 Book for the current academic year have been covered in the given assignment
No, all Printable Assignments for Interface Python with SQL Class 12 Computer Science have been given for free and can be downloaded in Pdf format
Latest syllabus issued for current academic year by CBSE has been used to design assignments for Interface Python with SQL Class 12
Yes, we have provided detailed answers for all questions given in assignments for Interface Python with SQL Class 12 Computer Science