Class12 Cs Set 1
Class12 Cs Set 1
Section – A
Q01. State True or False (1)
“Python is a platform independent, case sensitive and interpreted language”
Q02. Which of the following(s) is/are valid Identifier(s) in Python? (1)
(a) for (b) elif (c) _123 (d) None
Q03. What will be the output of the following Python code? (1)
T1=(1,2,[1,2],3)
T1[2][1]=3.5
print(T1)
1
Page 1 of 11
(b) File handle is used to read and write data to a file on disk. (c) All the functions that you
perform on a disk file can’t be performed through file handle.
(d) None of these
Q07. Fill in the blank: - (1)
_____________ command is used to add a new column into an existing table in SQL.
(a) UPDATE (b) INSERT (c) ALTER (d) CREATE
Q08. Which of the following command is a DDL command? (1)
(a) SELECT (b) GROUP BY (c) DROP (d) UNIQUE
Q09. Which of the following statement(s) would give an error after executing the following code? (1)
name_marks{'atul':88,'basab':45,'chetan':90} #Statement1
upgrade={} #Statement2
for key in name_marks.keys(): #Statement3
if (name_marks[key]>50): #Statement4
upgrade[key]=name_marks[key] #Statement5
print(upgrade) #Statement6
(a) Statement1 (b) Statement3 (c) Statement4 (d) Statement5
Q10. Fill in the blank: (1)
Number of records/ tuples/ rows in a relation or table of a database is referred to as ________
(a) Domain (b) Degree (c) Cardinality (d) Integrity
Q11. Which of the following statement is not true regarding opening modes of a file? (1)
(a) When you open a file for reading, if the file does not exist, an error occurs.
(b) When you open a file for writing, if the file does not exist, an error does not occur.
(c) When you open a file for appending content, if the file does not exist, an error does not occur.
(d) When you open a file for writing, if the file exists, new content added to the end of the file.
Q12. The __________________ clause is used for pattern matching in MySQL queries. (1)
(a) ALL (b) DESC (c) MATCH (d) LIKE
Q13. A __________________ specifies the distinct address for each resource on the Internet. (1)
(a) FTP (b) WWW (c) URL (d) HTTP
Q14. What will be the output of the following Python code? (1)
print(5<10 and 10<5 or 4<9 and not 3<-3)
(a) True (b) False (c) Error Message (d) None of these
Q15. Which of the following query is incorrect? Assume table EMPLOYEE with attributes (1)
EMPCODE, NAME, SALARY and CITY.
(a) SELECT COUNT(*) FROM EMPLOYEE;
(b) SELECT COUNT(NAME) FROM EMPLOYEE;
(c) SELECT AVG(SALARY) FROM EMPLOYEE;
(d) SELECT MAX(SALARY) AND MEAN(SALARY) FROM EMPLOYEE;
Q16. Which one of the following syntax is correct to establish a connection between Python and (1)
MySQL database using the function connect( ) of mysql.connector package? Assume that import
2
Page 2 of 11
mysql.connector as mycon is imported in the program
Q22. Explain the Relational Database Management System terminologies- Degree and Attribute of a (2)
relation. Give example to support your answer.
3
Page 3 of 11
Q23. (a) Write the full forms of the following: - (i) FTP (ii) POP (2)
(b) What is MAC address?
Q24. Predict the output of the Python code given below: def (2)
modify(L):
for C in
range(len(L)): if
C%2==1:
L[C]*=2 else:
L[C]//=2
#Main
N=[5,13,47,9]
modify(N)
print(N)
OR
Predict the output of the Python code given below:
T=(1,2,3,4,5,6,7,8,9)
T1=T[2:8:2]
T2=T[-2:-8:-2]
T3=T1+T2
print(T3[::-1])
Q25. Differentiate between WHERE and HAVING clause used in MySQL with appropriate example. (2)
OR
Explain the use of GROUP BY clause in MySQL with an appropriate example.
Section – C
Q26. (a) Consider the following tables – BILLED and ITEM (1+2)
Table: BILLED
BNO NAME CITY
1001 Ashok Delhi
1002 Manish Jaipur
1003 Rahul Lucknow
Table: ITEM
ITEMCODE INAME PRICE
11 HDD 2500
12 Keyboard 850
13 RAM 1100
4
Page 4 of 11
EMPID NAME DESIGNATION SALARY CITY
101 Harry Manager 90000 Delhi
102 Sam Director 120000 Mumbai
103 Peter Clerk 45000 Delhi
104 Jack Manager 85000 Kolkata
105 Robert Clerk 55000 Mumbai
Q27. (a) Write a method COUNT_W5() in Python which read all the content of a text file (3)
‘STORY.TXT’ and count &display all those words whose length is 6 character long. For
Example: - If the file content is as follows:
God made the mother earth and the man made countries; These
countries having states and states consists cities.
Then the output of the method will be
Six characters words are: - mother, These, having, states,cities,output,method The
total no of words with length of 6 characters is: 6
OR
(b) Write a function VC_COUNT() in Python, which should read each character of a text file
“THEORY.TXT” and then count and display all the vowels and consonants separately(including
upper cases and small cases).
Example:
If the file content is as follows:
A boy is playing there. There is a playground.
The VC_COUNT() function should display the output as:
Total vowels are: 14
Total consonants are: 22
5
Page 5 of 11
Q28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations ENGINEER and (2+1)
SALARY given below:
Table: ENGINEER
Table: SALARY
EID BASIC HRA DA
101 40000 3000 2000
102 45000 2500 2500
103 50000 5000 2800
104 35000 3000 1600
105 30000 2500 1200
(i) SELECT DEPARTMENT, COUNT(*) FROM ENGINEER GROUP
BY
DEPARTMENT;
(ii) SELECT MAX(DOJ), MIN(DOJ) FROM ENGINEER;
(iii) SELECT NAME, DEPARTMENT, (BASIC+HRA+DA) AS
“TOTALSALARY”
FROM ENGINEER, SALARY WHERE ENGINEER.EID =SALARY.EID;
(iv) SELECT NAME, HRA FROM ENGINEER E, SALARY S WHERE
E.EID=S.EID
AND GENDER = ’F’;
(b) Write a command to view the structure of a table.
Q29. Write a function INTERCHANGE(L), where L is the list of elements (3)
passed as argument to the function. The function returns another list
named ‘ChangedList’ that contain values interchanged as the even index
value with next consecutive odd index value of the L. For example:
If L contains [25,30,35,40,45]
The ChangedList will have [30,25,40,35,45 ]
6
Page 6 of 11
Q30. A list named as Record contains following format of for students: (3)
[student_name, class, city]. Write the following user defined functions to
perform given operations on the stack named
‘Record’:
(i) Push_record(Record) – To pass the list Record = [ ['Rahul', 12,'Delhi'],
[‘Kohli',11,'Mumbai'], ['Rohit',12,'Delhi'] ] and then Push an object
containing Student name, Class and City of student belongs to ‘Delhi’ to
the stack Record and display and return the contents of stack (ii)
Pop_record(Record) – To pass following Record [[“Rohit”,”12”,”Delhi”]
[“Rahul”,
12,”Delhi”] ] and then to Pop all the objects from the stack and at last display
“Stack Empty”
when there is no student record in the stack. Thus the output should be: -
[“Rohit”,”12”,”Delhi”]
[“Rahul”, 12,”Delhi”]
Stack Empty
OR
A list of numbers is used to populate the contents of a stack using a function push(stack, data)
where stack is an empty list and data is the list of numbers. The function should push all the
numbers that are even to the stack. Also write the function pop() that removes the top element of
the stack on its each call.
Section – D
Q31. Manoj is working in a mobile shop and assigned a task to create a table MOBILES with (1+1+2)
record of mobiles as Mobile code, Model, Company, Price and Date of Launch. After creation of the
table, he has entered data of 5 mobiles in the MOBILES table.
MOBILES
MCODE MODEL COMPANY PRICE DATE_OF_LAUNCH
M01 9PRO REALME 17000 2021-01-01
M02 NOTE11 MI 21000 2021-10-12
M03 10S MI 14000 2022-02-05
M04 NARZO50 REALME 13000 2020-05-01
M05 iPHONE12 APPLE 70000 2021-07-01
7
Page 7 of 11
(ii) Write the degree and cardinality of the above table, after removing one column and two
more record added to the table.
(iii) Write the statements to:
(a) Add a new column GST with data type integer to the table.
(b) Insert the value of GST in the new column as 18% of PRICE.
OR (Option for part iii only)
(iii) Write the statements to:
(a) To insert a new record of mobile as MobileCode – M06, Company Apple, Model-
iPHONE13, Price-110000 and Date of launch – ‘2022-03-01’.
(b) To delete the record of mobile with model as NARZO50.
Q32. Arun, during Practical Examination of Computer Science, has been assigned an (1+1+2) incomplete
search() function to search in a pickled file student.dat. The File student.dat is created by his Teacher
and the following information is known about the file.
• File contains details of students in [Rollno, Name, Marks] format.
• File contains details of 10 students (i.e. from Rollno 1 to 10) and separate list of
Arun has been assigned the task to complete the code and print details of Roll Number 7.
8
Page 8 of 11
computers to be installed in each block is given below. The Head Quarter of the Institute is in Delhi.
You as a Network expert have to answer the queries raised by their board of directors as given (i) to (v).
JAIPUR CAMPUS
MBA ADMIN
MBBS BTECH
(i) Suggest the most appropriate block to house the SERVER in Jaipur Campus to get the
best and effective connectivity. Justify your answer.
(ii) Suggest a device/software to be installed in Jaipur campus to take care of data security.
(iii) Suggest the best wired medium and draw the cable layout to economically connect all the
blocks with the campus.
(iv) Suggest the placement of the following devices with appropriate reasons:
(a) Switch / Hub (b) Repeater
(v) Suggest a protocol that shall be needed to provide video conferencing solution between
Jaipur campus and Delhi Head Quarter.
Please note that there is internal choice in Q34 & Q35.
Q34. (a) Write the output of the code given below: (2+3) def Funstr(S):
T="" for i
in S: if
i.isdigit():
T=T+i
return T
A="Comp.Sc.- 083"
B=Funstr(A) print(A,'\n',B,
sep="#")
9
Page 9 of 11
(b) The code given below inserts the following record in the table employee:
EmpNo – integer
EmpName – string
Salary – integer
City – string
Note the following to establish connectivity between Python and MYSQL:
• Username is root Password is tiger
• The table exists in a MYSQL database named COMPANY.
• The details (EmpNo, EmpName, Salary and City) are to be accepted from the user.
10
Page 10 of 11
PName – string Price
– integer
Note the following to establish connectivity between Python and MYSQL:
• Username is root
• Password is tiger
• The table exists in a MYSQL database named school.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those products whose Priceare
greater than 500.
Statement 3- to read the complete result of the query (records whose price are greater than
500) into the object named data, from the table Product in the database. import
mysql.connector as mysql def sql_data():
con1=mysql.connect(host="localhost",user="root",passwd="tiger", database="ABCD")
mycursor=_______________ #Statement 1 print("Product detail whose price greater
than 500 are : ")
_________________________ #Statement 2
data=__________________ #Statement 3 for
i in data: print(i) print()
Q35. How CSV files are different from normal text files? (5)
Write a program in Python that defines and calls the following user defined functions:
(i) INSERT() – To accept and add data of a Student to a CSV file ‘Sdetails.csv’. Each record
consists of a list with field elements as RollNo, Name, Class and Marks to store roll
number of students, name of student, class and marks obtained by the student.
(ii) COUNTROW() – To count the number of records present in the CSV file named
‘Sdetails.csv’.
OR
Write syntax to create a reader object and write object to read and write the content of a CSV
file. Write a Program in Python that defines and calls the following user defined functions:
(i) ADD() – To accept and add data of an employee to a CSV file ‘empdata.csv’. Each record
consists of a list with field elements as Eid, Ename, Salary and City to store employee id ,
(ii) SEARCH()- To display the records of the employees whose salary is more than 50000.
11
Page 11 of 11