12 Computer Science Sp 01 A
12 Computer Science Sp 01 A
Maximum Marks: 70
Time Allowed: : 3 hours
General Instructions:
Section A
1. State true or false:
In a nested loop, a break statement terminates all the nested loops in one go.
a) True
b) False
2. A relational database consists of a collection of:
a) Fields
b) Keys
c) Records
d) Tables
3. fetchall() method fetches all rows in a result set and returns a:
a) Tuple of strings
b) Tuple of lists
c) List of tuples
d) List of strings
4. What is the output of the below program?
def printMax(a, b):
if a > b:
print(a, 'is maximum')
elif a = b:
print(a, 'is equal to', b)
else:
print(b, 'is maximum')
printMax(3, 4)
a) 3 is maximum
OR
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)
a, b = 10, 15
x = 20
y = 25
a = x + y - b
x = a + b - y + 10
z = y + b * 3 + a
x = 50
a = x + y + z
print("a :", a)
print("b :", b)
print("x :", x)
OR
OR
Write a function count_Dwords () in Python to count the words ending with a digit in a text file "Details.txt".
Example:
If the file content is as follows:
On seat2 VIP1 will sit and
On seat1 VVIP2 will be sitting
Output will be:
Number of words ending with a digit are 4
27. Explain the use of a default parameter in a Python function with the help of a suitable example.
28. Explain the two types of duplex communication.
Section C
29. Write a method in Python to find and display the prime number between 2 to n. Pass n as an argument to the method.
OR
Write functions in Python for InsertQ(Names) and RemoveQ(Names) for performing insertion and removal operations
with a queue of list which contains names of students. The function must check for Empty Queue.
30. Write the output of SQL queries (a) to (d) based on the table VACCINATION_DATA given below:
TABLE: VACCINATION_DATA
OR
Write definition of a method OddSum(NUMBERS) to add those values in the list of NUMBERS, which are not even.
Section D
32. Write a program to implement a stack for these book details (book no., book name). That is, now each item node of the
stack contains two types of information - a book no. and its name. Just implement Push and display operations.
OR
A line of text is read from the input terminal into a stack. Write a program to output the string in the reverse order, each
character appearing twice.
(ie.g., the string a b c d e should be changed to ee dd cc bb aa)
33. A binary file "PATIENTS.dat" has structure (PID, NAME, DISEASE).
Write the definition of a function countrec() in Python that would read contents of the file "PATIENTS.dat" and
display the details of those patients who have the DISEASE as 'COVID-19'. The function should also display the total
number of such patients whose DISEASE is 'COVID-19'.
34. Study the following tables DOCTOR and SALARY and write SQL commands for the questions (i) to (v).
TABLE: DOCTOR
TABLE: SALARY
OR
Consider the following tables PRODUCT and CLIENT. Write SQL commands for the following statements.
Table: PRODUCT
Table: CLIENT
As a network expert, you need to suggest the network plan as per (i) to (iv) to the authorities keeping in mind the
Expected number of Computers to be installed at various locations in the University are as follows:
Office Block 10
TABLE: BOOK
TABLE: MEMBER
OR
Consider the following tables CABHUB and CUSTOMER and answer the following parts of this question :
Table: CABHUB
Table: CUSTOMER
Solution
Section A
1. (b) False
Explanation: False
2. (d) Tables
Explanation: A relational database consists of a collection of tables that store interrelated data.
3. (c) List of tuples
Explanation: List of tuples
4. (c) 4 is maximum
Explanation: Here, we define a function called printMax that uses two parameters called a and b. We find out the
greater number using a simple if..else statement and then print the bigger number.
5. The above code will produce error as the statement above is not correct form of dictionary, which has keys and values.
6. (a) Twisted pair cable
Explanation: Twisted pair cable is the least expensive transmission media.
7. (a) x
Explanation: x
8. (b) 5
Explanation: A list is getting added in list l1 which will be counted as one item for the list.
9. (c) Acts like a WHERE clause but is used for groups rather than rows.
Explanation: Acts like a WHERE clause but is used for groups rather than rows.HAVING is used to filter values after
they have been groups.
10. myfile.write("Hello world!")
File object is myfile, and write() function writes string "Hello World!" into the file.
11. (a) True
Explanation: True
12. (a) OVERFLOW
Explanation: When a stack, implemented as an array/list of fixed size, is full and no new element can be
accommodated, it is called an OVERFLOW.
13. The aggregate function that can display the cardinality (number of rows) of a table in SQL is COUNT.
14. (c) WAN
Explanation: WAN spans a large geographical area, often a country or a continent and uses various commercial and
private communication lines to connect computers.
15. (d) Error
Explanation: ++ is not defined as an increment operator in python.
16. (b) Dictionary
Explanation: Dictionary
17. (c) Fibre optic
Explanation: The transmission capacity of optical fibre cable is 26,000 times higher than that of twisted pair cable.
18. (c) TCP
Explanation: TCP
19. (b) Both A and R are true but R is not the correct explanation of A.
Explanation: The tuple items cannot be deleted individually by using the del keyword as tuple is immutable. To delete
OR
OR
The length of this tuple is 3 because there are just three elements in the given tuple. Because a careful look at the given
tuple yields that tuple t is made up of:
t1 = "a", 1
OR
def count_Dwords():
with open ("Details.txt", 'r') as F: # ignore 'r'
S=F.read()
Wlist = S.split()
count = 0
for w in wlist:
if w [-1].isdigit():
count+=1
print ("Number of words ending with a digit are", count)
OR
def count_Dwords():
count=0
myfile=open("Details.txt")
S=myfile.read()
Wlist=S.split()
for W in Wlist:
if i[-1] in "0123456789":
count=count+1
myfile.close()
print("Number of words ending with a digit are",count)
27. In Python, a default parameter is defined with a fallback value as a default argument. Such parameters are optional
during a function call. If no argument is provided, the default value is used, and if an argument is provided, it will
overwrite the default value. greet("Ankit", "How do you do?")
28. There are mainly two types of duplex communication:
i. Full duplex: In this type of transmission, two bitstreams can be simultaneously transmitted over the links at the same
time, one going in each direction, i.e., sending as well as receiving the data. For example, in a telephone
conversation, two people communicate, and both are free to speak and listen at the same time.
ii. Half-duplex: In this type of transmission, data can flow in only one direction at a time i.e., either sending or
receiving data at a time. For example, in walkie-talkies, the speakers at both ends can speak, but they have to speak
OR
def InsertQ(Names):
Name=raw_input("enter Name to be inserted: ")
Names.append(Name)
def DeleteQ(Names):
if (Names==[]):
print "Queue empty"
else:
print "Deleted Player’s Name is: ",Names[0]
del(Names[0])
30. a. SELECT Name, Age FROM VACCINATION_DATA WHERE DOSE2 IS NOT NULL AND Age > 40;
Name Age
Harjot 55
Srikanth 43
b. SELECT City, COUNT(*) FROM VACCINATION_DATA GROUP BY City;
City COUNT(*)
Delhi 2
Mumbai 2
Kolkata 1
c. SELECT DISTINCT CITY FROM VACCINATION_DATA;
CITY
Delhi
Mumbai
Kolkata
d. SELECT MAX(Dose1), MIN(Dose2) FROM VACCINATION_DATA;
MAX(Dose1) MIN(Dose2)
2022-01-01 2021-07-20
OR
For example, in the following code, x, xCubed are global variables and n and cn are local variables.
def cube(n):
cn = n * n * n
return cn
x = 10
xCubed = cube(x)
print(x, "cubed is", xCubed)
OR
def OddSum(NUMBERS) :
odd_sum = 0
for num in range (len(NUMBERS)):
if (NUMBERS[num] % 2 != 0:
odd_sum = odd_sum + NUMBERS [num]
print odd_sum
Section D
32. " " "
Stack: implemented as a list
top: integer having a position of a topmost element in Stack
"""
def cls( ):
print("\n"* 100)
def is Empty(stk) :
if stk== [ ] :
return True
else :
return False
def Push(stk, item) :
stk.append(item)
top = len(stk) - 1
def Display(stk) :
if isEmpty(stk) :
print ("Stack empty”)
OR
MAX_SIZE = 1000
stack = [0 for i in range(MAX_SIZE)]
top = 0
def isEmpty ( ):
global top
return top == 0
def push(x):
global stack,top
if top >= MAX_SIZE:
return
stack[top]= x
top += 1
def pop( ):
global stack,top
if isEmpty( ):
34. i. SELECT NAME FROM DOCTOR WHERE DEPT='MEDICINE' AND EXPERIENCE > 10;
ii. SELECT AVG(BASIC + ALLOWANCE) FROM SALARY WHERE SALARY.ID IN(SELECT ID FROM
DOCTOR WHERE DEPT='ENT');
iii. SELECT MIN(ALLOWANCE) FROM SALARY WHERE SALARY.ID IN(SELECT ID FROM DOCTOR WHERE
SEX ='F');
iv. SELECT MAX(CONSULTATION) FROM SALARY WHERE SALARY.ID IN(SELECT ID FROM DOCTOR
WHERE SEX='M');
v. SELECT * FROM DOCTOR
WHERE EXPERIENCED>12;
OR
OR
i. 4
ii. 35 12
iii. Invalid query
iv. SX4
C Class
To practice more questions & prepare well for exams, download myCBSEguide.com App. It provides complete
study material for CBSE, NCERT, JEE (main), NEET-UG and NDA exams. Teachers can use Examin8.com App to
create similar papers with their own name and logo.