Practice Qp 12cs
Practice Qp 12cs
Section-A
1. Identify the name(s) from the following that cannot be used as 1
identifiers in Python:
asaword22, 22ndyear, date26-10-2022, _my_file_2
2. Which of the following will delete key-value pair where key is 1
Book_name from a dictionary ‘Book’?
a) delete Book(“Book_name”)
b) del.Book[“Book_name”]
c) del Book[“Book_name”]
d) del Book
3. What will be the output of the following code? 1
a) 4
b) 8.0
c) 8
d) 10
4. What will be the result of following expression: 1
(10>12) and (“a”+1<55)
a) True
b) False
c) Error
d) None
5. The pickle module in python is used for: 1
a)Serialize any python object structure
b)De-serialize any python object structure
c)Both a & b
d)Pickle module cannot be applied on binary files
6. Study the following code and predict the output. 1
a) 5
b) 5.0
c) 2.0
d) Error
Page 1 of 11
7. Given the following dictionaries 1
dict_exam={"Exam":"AISSCE", "Year":2023}
dict_result={"Total":500, "Pass_Marks":165}
Which statement will merge the contents of both dictionaries?
a) dict_exam.update(dict_result)
b) dict_exam + dict_result
c) dict_exam.add(dict_result)
d) dict_exam.merge(dict_result)
8. _______function is used to change the position of the File Handle to 1
a given specific position.
a) seek() b) tell() c) read() d) load()
9. Which of the following statements would give an error after 1
executing the following code?
T= ‘green’ # ---- Statement 1
T[0]= ‘G’ #---- Statement 2
T=[1 , ‘B’ ,14.5 ] #---- Statement 3
T[3]=15 #---- Statement 4
Options:-
(a) Statement 2 and 4
(b) Statement 1 and 2
(c) Statement 3 and 4
(d) Statement 1 and 3
(a) Both A and R are True and R is the correct explanation for A
(b) Both A and R are True and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
Section-B
19. Following code is having some errors. Rewrite the code after 2
correcting and underlining each correction:
x == 20
def printme():
y = x + 10
sum = 0
for i in range(x,y)
Page 3 of 11
if i%3=0:
sum=sum+i+1
Elseif:
sum += 2
return(sum)
20. (i)Expand the following terms: 2
(a) FTP (b) XML
(ii) Write one advantage and one disadvantage of using Fiber Optic
Cable.
(OR)
list1 = [2, 3, 3, 2, 5, 3, 2, 5, 1, 1]
counts = {}
ct = 0
lst = []
for num in list1:
if num not in lst:
lst.append(num)
counts[num] = 0
ct = ct+1
counts[num] = counts[num]+1
print(counts)
for key in counts.keys():
counts[key] = key * counts[key]
print(counts)
23. Write a program to print all elements in a list those have only single 2
occurrence.
Example: if contents of list is [7, 5, 5, 1, 6, 7, 8, 7, 6].
Page 4 of 11
Your output should be: 1 8
24. Jacob has created a table named “Student” containing the columns 2
Admno, Sname and Marks. After creating the table, he realized that
he has forgotten to add an attribute named Class of data type string
in the table. Help him to write an SQL command to add the
attribute Class to the table and this attribute cannot be blank.
Also help him to write the command to update the mark of the
following student record in the table to 98.
Admno Sname Marks
102 Preethi 96
26. (a) Observe the following table and answer the question (i) and (ii) 3
TABLE: VISITOR (2+1)
VISITORID VISITORNAME CONTACTNUMBER
V001 VIJAY 9566467788
V002 KRITHI 9745868693
V003 PREETHI 9375673757
V004 KRITHI 9124576868
(i) Write the name of most appropriate columns which can be
considered as Candidate keys?
(ii) Insert the following data into the attributes VISITORID,
VISITORNAME and CONTACTNUMBER respectively in the given
table VISITOR.
VISITORID=“V005”,VISITORNAME=“VISHESH”,
Page 5 of 11
CONTACTNUMBER= 9907607474
(b) In SQL, what is the use of IS NULL operator?
27. Predict the output of the python code given below: 3
def Convert(Old):
l=len(Old)
New=""
for i in range(0,l):
if Old[i].isupper():
New=New+Old[i].lower()
elif Old[i].islower():
New=New+Old[i].upper()
elif Old[i].isdigit():
New=New+"*"
else:
New=New+"%"
return New
Older="InDIa@2020"
Newer=Convert(Older)
print(Newer,"is the new string")
28. Write a function DISPLAYWORDS( ) in python to display the count 3
of words starting with “t” or “T” in a text file ‘STORY.TXT’.
If the “STORY.TXT” contents are as follows:
The teacher looked at the student.
The output of the function should be: 3
OR
29. Write a function in Python PUSH (St, Lst) where ‘Lst’ is a list of 3
numbers. From this list push all numbers which are not divisible by
6 into a stack implemented by using a list ‘St’. Display the stack if it
has at least one element, otherwise display appropriate error
message.
30. (a) Write a output for SQL queries (i) to (iv), which are based on the 3
given tables: SCHOOL and ADMIN: (2+1)
Page 6 of 11
(i) SELECT SUBJECT, SUM (PERIODS)
FROM SCHOOL GROUP BY SUBJECT;
Section-D
Page 7 of 11
Based on the data given above answer the following questions:
(a) Identify the most appropriate column which can be set as
primary key.
(b) If 4 rows are added and one column is removed, identify the
Degree and Cardinality of the table.
Section-E
Page 9 of 11
(i) Suggest the most appropriate location of the server inside the
Nagpur Campus to get the best connectivity for maximum
number of computers. Justify your answer.
(ii) Suggest and draw the cable layout to efficiently connect various
buildings within the Nagpur campus for connecting the
computers.
(iii) Which of the following will you suggest to establish the online
face-to-face communication between the people in the ADMIN
office of Nagpur Campus and Mumbai Head office?
(a) Cable TV (b) E-mail (c) Video Conferencing (d)Text Chat
(iv) Suggest the placement of following devices with appropriate
reasons:
(a) Switch/Hub (b) Repeater
(v) Suggest the device/software to be installed in Nagpur Campus
to take care of data security and unauthorized access.
34. (a) Write the output of the Code given below: 5
x = 15 (2+3)
def add(p=2, q=5):
global x
x = p+q+p*q
print(x,end='@')
m = 20
n = 5
add(m,n)
add(q=10, p = -3)
(b) The code given below reads the following record from the table
named Employee and displays only those records who have a Salary
greater than 75000:
• EmpNo – integer
• EmpName – string
• Designation – string
• Salary – integer
Note the following to establish connectivity between Python and
MySQL:
• Username is root
• Password is sales_emp
• The table exists in a MySQL database named “Office”.
Page 10 of 11
Write the statements for missing statements to complete the above
code:
(i) Statement 1 – To form the cursor object
(ii) Statement 2 – To execute the query that extracts records of
those employees whose salaries are greater than 75000.
(iii) Statement 3 – To read the complete result of the query
(records whose salaries are greater than 75000) into the
object named ‘data’ from the table Employee in the
database.
******
Page 11 of 11