Cs Pre-Board 1
Cs Pre-Board 1
(P.T.O.]
ZZZ-1207
(d) None of these
Predict the output for the following code snippet: 1
t= 4,
print(type(t))
(a) <class "int'> (b) <class "tuple'>
(c) No output (d) error
10. The syntax of seek () is: 1
file_object.seek (offset [, reference point])
What is the default value of reference_point?
(a) 0 (b) 1 (c) 2 (d) 3
11 State whether the following statement is True or False: 1
"Every syntax error is an exception but every exXception cannot be
a syntax error." e
12. Write the output of the following Python code: 1
a = 20
return X
X = 15
[P.T.O.]
ZZZ-1207
Reason(R): The aggregate functions are used to perform some
fundamental arithmetic tasks such as Min(), Max(), Sum() etc..1
f SECTION-B( 7 X2=14 MARKS)
22
Mithilesh has written a code to input a number and
factorial and then finally print the result in the evaluate its
of the <number> is format: "The factorial
<factorial value>" His code is having errors.
Rewrite the correct code and underline the
f= 0
corrections made.
num = input("Enter a number: ")
n =num
nent
else:
print (The factorial of: ", num "is", f)
23 Predict the output of the foilowing: 2
1
for i in range (1, 15, 2):
temp = i
if i % 3 = = 0:
1 temp = i + 1
.tions. elif i % 5 = = 0:
continue
elif i = = 11:
for A
1for A
break print(temp, end = '$)
24 If L =[3,5,2,7,8,12,2,19] and L1 = [4,6,3,2,7,12,9] then 2
(i) (A) Write a statement to merge both the lists.
OR
Jle, we
(B) Write a statement to sort the elements in place of list L.
in the (ii) (A) Write a statement to get a new list SL with the elements
1 of L1 in descending order.
ates tht OR
esult.
[P.T.O. [P.T..]
ZZZ-1207 6
(B) Write a statement to insert the last element of list L1 in the
list Lat 5h index.
25 Identify the correct output(s) of the following code. Also write
the minimum and the maximum possible values of the variable
b.
import random
a="Wisdom"
b=random.randint(1,6)
for i in range(0,b,2):
print(a[i],end=#)
AA) W# (B) W# i#
C) W # s # (D) W # i # s #
26 What is the difference between primary key and alternate key? Give
example of each. 2
27 () (A) Write the command to add a column
Percentage in the
Marks. Where the data should be entered as decimal number ie. table
78.3
OR
(B) Write the constraint that will provide value to a column if no
value is inserted in that column.
(ii) (A) Write the command to change the name of a column from
Comm to Commission in the table Product.
OR
(B) Write the constraint that will allow null value but not duplicate
values in the column of a table.
7 ZZZ-1207
For ex - if Para. txt contains the following content
He lives in AB-66, AB Type Quarters.
Then the function should display:
Upper case alphabets - 7
Lower case alphabets 18
Digits 2
OR
(B) Write a method/function countwords() in Python to read
contents from a text file 'DECODE.TXT' to count and return
the occurrence of those worlds which are having 5 or more
characters.
For ex -if DECODE.TXT content is :
[P.T.0.]
9 Z7Z-1207
32 (A) () Explain Catching exceptions using try and except block.
(1) Give an example code to handle ZeroDivisionError using try
and except block. The code should display the message
"Denominator can't be zero" in case of ZeroDivisionError
exception, and the message "Some other error occurred" in
case of any other exception.
OR
(B) () When is l0Error exception raised in
(ii) Python?
Give an example code to handle IOError
block. The code should display the using try and except
in case of lOError message "File not found
exception, and the message "Some other
error occurred" in case of any
33 other exception. 4
Mr. Mahesh is a Python
to maintain the records ofprogrammer working in a school. He has
the sports students. He has
CSv file named sports.csv to store created a
the details. The
sports.csv :[sport_id, competition, prize_won] structure
is of
Where sport id is sport id (integer)
Competition is competition name (string)
Prize_won is (Gold", "Silver", "Bronze")
Mr. Mahesh wants to write the
following user defined functions:
Add details(): to accept the details of
file, "sports.csv". student and add to a csv
Count Medal(): to display the name the
students have won "Gold medal". competitions in which
Help him in writing the code of both the functions.
34 Consider the tables Games and Players given below: 4
TABLE GAMES
Gcode GameName Type Number Prize Money
101 Carrom BoardIndoor 2 5000
102 Badminton Outdoor2 12000
103 Table Tennis Indoor 4 Null
104 Chess Indoor 2 9000
105 Lawn Tennis Outdoor4 25000
[P.T.0.]
ZZZ-1207 10
TABLE: PLAYERS
Pcode Name Gcode
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103
Write SQL queries for the following:
() Display the game type and average number of games played
in each type.
(i) Display prize money, name of the game and name of the
players from the tables games and players.
(ii) Display the type of games without, repetition.
(iv) (A) Display the name of the games and prize money of those
games whose prize money is known.
OR
Logistics Block
[P.T.O.]
ZZZ-1207 12
Distance between various blocks/locations:
HR block to ACcOunts
blocks 400 meters
Accounts block to Logistics block 200 meters
[P.T.O.]