0% found this document useful (0 votes)
42 views

Practice Qp 12cs

Uploaded by

padmavathy20788
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Practice Qp 12cs

Uploaded by

padmavathy20788
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

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

10. Which of the following is a DML command? 1


a) SELECT
b) UPDATE
c) INSERT
d) All
11. Which of these is not an example of unguided media? 1
a) Optical Fibre Cable
b) Radio wave
c) Bluetooth
d) Satellite
12. Name the protocol that is used to send emails. 1
a) FTP
b) SMTP
c) HTTP
d) TELNET
13. Suresh wants to open the binary file student.dat in read mode. He 1
writes the following statement but he does not know the mode.
Help him to find the same.
F=open(‘student.dat’, ____)
Page 2 of 11
a) r
b) rb
c) w
d) wb
14. Name the clause used in query to place the condition on groups in 1
MySQL.
15. All aggregate functions except -------------------------ignore null values 1
in their input collection.
(a)max() (b) count(*) (c) Avg() (d) sum()
16. After establishing database connection, database-------------------- is 1
created so that the SQL query may be executed through it to obtain
resultset.
(a)connector (b) connection (c) cursor (d) object

Q17 and 18 are ASSERTION AND REASONING based questions. Mark


the correct choice as

(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

17. Assertion (A):- A default argument can be skipped in the function 1


call statement.
Reasoning (R):- The default values for parameters are considered
only if no value is provided for that parameter in the function call
statement.
18. Assertion (A): CSV files are delimited files that store tabular data 1
where comma delimits every value.
Reason (R): For writing onto a CSV file, user data is written on
txt.writer object which converts the user data into delimited form
and writes it on to the csv file.

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)

(i)Expand the following terms:


(a) SMTP (b) URL
(ii) Write one difference between Circuit Switching and Packet
Switching.
21. (i) If a = (1, 2, 3), what is the difference (if any) between a*3 and 2
[a, a, a]?

(ii) Consider a={1:10, 2:20, 3:30, 4:40}


(a) Write code to delete the second element using del command.
(b) Write code to delete the third element using pop() function.
22. Predict the output of the following code: 2

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

25. What possible output(s) are expected to be displayed on screen at 2


the time of execution of the program from the following code? Also
specify the minimum and maximum values that can be assigned to
the variable ‘End’.
import random
Colours = ["VIOLET","INDIGO","BLUE","GREEN",\
"YELLOW","ORANGE","RED"]
End =random.randrange(2)+3
Begin =random.randrange(End)+1
for i in range(Begin,End):
print(Colours[i],end="&")
(i) INDIGO&BLUE&GREEN&
(ii) VIOLET&INDIGO&BLUE&
(iii) BLUE&GREEN&YELLOW&
(iv) GREEN&YELLOW&ORANGE&
Section-C

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

Write a function in python that counts the number of “Me” and


“My” (in lower case also) words present in a text file “STORY.TXT”.
If the “STORY.TXT” contents are as follows:
My first book was Me and My Family. It gave me chance to be known
to the world.
The output of the function should be: Count of Me/My in file: 4

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;

(ii) SELECT TEACHERNAME, GENDER


FROM SCHOOL, ADMIN
WHERE DESIGNATION = ‘COORDINATOR’ AND
SCHOOL.CODE=ADMIN.CODE;

(iii) SELECT COUNT (DISTINCT SUBJECT)


FROM SCHOOL;

(iv) SELECT TEACHERNAME, SUBJECT


FROM SCHOOL WHERE SUBJECT LIKE “%s”;

(b) Write a query to display number of teachers in each subject.

Section-D

31. Consider the table “EMPLOYEE” as follows: 4

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.

(c) Write MYSQL query to perform the following tasks:


(i) Add a new column EXPERIENCE with datatype float.
(ii) Increase the salary for a person by 10% whose experience is
greater than 15 years.
OR (Option for part c only)
(i) Delete a column SALARY.
(ii) Increase the salary of a person by 5% whose name ends with
the character “N”.

32. Abhisar is making a software on “Countries & their Capitals” in 4


which various records are to be stored/retrieved in CAPITAL.CSV
data file. It consists some records (Country & Capital). He has
written the following code in python. As a programmer, you have
to help him to successfully execute the program.
import csv
def AddNewRec(Country,Capital):
# Function to add a new record in CSV file
f=open("CAPITAL.CSV",________,newline='')# Statement-1
fwriter=csv.writer(f)
fwriter.writerow([Country,Capital])
f._________()# Statement-2
def ShowRec(): # Fn. to display all records from CSV file
with open("CAPITAL.CSV","r") as NF:
NewReader=csv._______(NF) # Statement-3
for rec in NewReader:
print(rec[0],rec[1])
AddNewRec("INDIA","NEW DELHI")
AddNewRec("CHINA","BEIJING")
ShowRec() # Statement-4

(a)Write the file mode to be passed to add new record in Statement-1


(b) Fill in the blank in Statement-2 to close the file.
Page 8 of 11
(c)Fill in the blank in Statement-3 to read the data from a csv file.
(d) Write the output which will come after executing Statement-4.

Section-E

33. Superior Education Society is an educational Organization. It is 5


planning to setup its Campus at Nagpur with its head office at
Mumbai. The Nagpur Campus has 4 main buildings – ADMIN,
COMMERCE, ARTS and SCIENCE.
You as a network expert have to suggest the best network related
solutions for their problems raised in a to e, keeping in mind the
distances between the buildings and other given parameters:

Shortest distances between various buildings:


ADMIN to COMMERCE - 55 m
ADMIN to ARTS - 90 m
ADMIN to SCIENCE - 50 m
COMMERCE to ARTS - 55 m
COMMERCE to SCIENCE - 50 m
ARTS to SCIENCE - 45 m
MUMBAI Head Office to NAGPUR Campus – 850 KM
Number of Computers installed at various buildings are as
follows:
ADMIN – 110
COMMERCE – 75
ARTS – 40
SCIENCE – 12
MUMBAI Head Office – 20

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.

35. a) Differentiate between r+ and w+ file modes in Python. 5


(2+3)
b) Write a function Copy_Game() in that would read the contents
from the file GAME.DAT and creates a file named BASKET.DAT
copying only those records from GAME.DAT where the game name
is “BasketBall”.(game.dat - gamename, participants). Assume that info
is stored in the form of list.

******

Page 11 of 11

You might also like