CLASS 12 Midterm QP With Ans (Aug'23)
CLASS 12 Midterm QP With Ans (Aug'23)
General Instructions:
1) This question paper contains five Sections-Section A to Section E.
2) All questions are compulsory.
3) Section A, consists of 10 questions. Each question carries 1 mark.
4) Section B, consists of 3 questions. Each question carries 2 marks.
5) Section C, consists of 2 questions. Each question carries 3 marks.
6) Section D, consists of 2 questions. Each question carries 4 marks.
7) Section E, consists of 1 question. This question carries 5 marks.
SECTION A
1. What type of objects can be used as keys in dictionaries? 1
Answer =
2. Which of the following arguments works with implicit values that are
used if no value is provided? 1
(a) keyword
(b) required
(c) variable-length
(d) default
Ans:
d
3. A library can have multiple modules in it.(T/F) 1
Ans:
T
4. Add one column Email of data type VARCHAR and size 30 to the table
Customer. 1
Answer =
Ans: C
6. Which line of code will cause an error? 1
2. print(num [0])
3. print(num[3][0])
4. print (num[5])
(a) Line 3
(b) Line 2
(c) Line 4
(d) Line 1
Ans:
(c )
7. What will be the output generated by the following snippet? 1
k=1
i = a[1] + 1
j = a[2] +1
m = a[k+1]
print (i, j, m)
(a) 11 15 16
(b) 11 16 15
(c) 11 15 15
(d) 16 11 15
Ans:
(b)
Answer =
def foo():
try:
print(1)
finally:
print(2)
foo()
a)
b) a) 1 2
b) 1
c) 2
d) none of the mentioned
Answer: a
SECTION B
Ans:
apple
PEAR
PEACH
grapefruit
>>>
12. Write a program that reads a string and checks whether it is a
palindrome string or not. 2
Answer =
string = input("Enter a string :")
length = len(string)
mid = int(length / 2)
rev = -1
for a in range (mid) :
if string[a] == string[rev] :
a += 1
rev -= 1
else :
print(string, "is not a palindrome")
break
else :
print(string, "is a palindrome")
13. What is the difference between the formal parameters and actual
parameters? What are their alternative names? Also, give a suitable
Python code to illustrate both. 2
Answer :-
SECTION C
14. Write a Python function that accepts a string and calculate the number
of uppercase letters and lowercase letters. 3
Ans:
def string_test(s):
d = {"UPPER_CASE" : 0, "LOWER_CASE" : 0}
for c in s:
if c.isupper():
d["UPPER_CASE"] += 1
elif c.islower ():
d["LOWER_CASE"] += 1
else:
pass
print ("Original String : ", s)
print ("No. of Uppercase characters : ", d["UPPER_CASE"])
print ("No. of Lowercase characters : ", d["LOWER_CASE"])
sentence = input ("Enter sentence :- ")
string_test(sentence)
15. Write SQL queries for (i) to (iii),which have the table name as Student. 3
(ii) To display Class, Dob and City whose marks is between 450 and
551.
(iii) To display Name, Class and total number of students who have
secured more than 450 marks, class wise.
Answer =
(i)
SELECT * FROM Student ORDER BY Name;
(ii)
SELECT Class, DOB, City FROM Student
WHERE Marks BETWEEN 450 AND 551;
OR
(iii)
SELECT Name, Class, COUNT(*) FROM Student
GROUP BY Class HAVING Marks > 450;
SECTION D
16. With reference to the table below, answer the questions that
follows: 4
Table: Employees
Empid Firstname Lastname Address City
24 Friends
244 Manila Sengupta street New Delhi
121 Harrison
400 Rachel Lee St. New York
Write the SQL commands for the following using above tables:
(i) To show firstname, lastname, address and city of all employees
living in Pairs.
(ii) To display the content of Employees table in descending order of
Firstname.
(iii) To display the firstname, lastname and total salary of all managers
from the tables Employes and Emp Salary, where total salary is
calculated as Salary + Benefits.
(iv) To display the maximum salary among managers and clerks from
the table EmpSalary.
Answer =
(i)
Select firstname, lastname, address, city from Employee where city =
“Paris”;
(ii)
Select * from Employee order by Firstname desc;
(iii)
Select firstname, lastname , (Salary + Benefits) “total salary” from
Employee natural join EmpSalary ;
(iv)
Selec max(Salary) from EmpSalary where Designation in
(“Manager”, “Clerk”) ;
Output:
(i)
Fristname salary
Rachel 32000
Peter 28000
(ii)
count(distinct
designation)
4
(iii)
designation Sum(salary)
Manager 215000
Clerk 135000
(iv)
Sum(Benefits)
32000
import random
SEL=random. randint (1, 3)
ANIMAL = ["DEER", "Monkey", "COW", "Kangaroo"]
for A in ANIMAL:
for AA in range (0, SEL):
print (A, end ="")
print ()
(i) (ii) (iii) (iv)
KANGAROOKANGAROO KANGAROO
(v) Write SQL command to change the JOBID to 104 of the EMPLOYEE
with ID as E4 in the table ‘EMPLOYEE’
(iv) JOBID