0 ratings0% found this document useful (0 votes) 32 views4 pagesWorksheet - Python Revision Tour
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
COMPUTER SCIENCE
PYTHON REVISION TOUR 1 & 2
WORKSHEET
Q01. State True or False.
Identifiers are the names used to identify a variable, a function in a program.
Ans /TRUE
|Q02. Which of the following is a valid keyword in python?
a)false b) return ~—c) non_local_d) none
[Ans |b) return
|Q03. |Given the following Tuple.
[Tup=(10,20,30,50)
hich of the following statements will result in an error?
a) print(Tup[0] b) [Link](2,3) c)print(Tup[1:2]) d)
print(len(Tup))
[Ans |b) [Link](2,3)
\Q04. \Consider the given expression.
5 < 10 and 12 >7 or not 7>4
hich of the following will be the correct output, if the given expression is
evaluated?
a) True b) False c)NONE — d) NULL
[Ans |a) True
{Q05. |Select the correct output of the code:
\S="Amrit Mahotsav @ 75"
|A=[Link](" ")
[print(A)
la) (Amrit Mahotsav', '@’, '75') b) ‘Amrit’, 'Mahotsav', '@''75')
) (Amrit, '', 'Mahotsav @ 75’) d) (‘Amrit’, 'Mahotsav @ 75')
Ans_ |c) (‘Amrit','', 'Mahotsav @ 75')
Q06. |___ function is used to arrange the elements of a list in ascending order.
) sort() —_b) arrange() c) ascending() _d) asort()
[Ans fa) sort()
{Q07. |Which of the following operator will return either True or False?
+= b) t= oF d) =
[Ans _ fb) !={Q08.
Which of the following statement(s) would give an error after executing the
following code?
\Stud = { “Murugan” : 100, “Mithun! : 95 } # Statement I
print( Stud[95] ) # Statement 2
‘Stud [ “Murugan” ] = 99 # Statement 3
print( [Link]() ) # Statement 4
print( Stud ) # Statement 5
a) Statement 2 b)Statement3 cc) Statement4 d) Statements 2 and 4
[Ans {d) Statements 2 and 4
{Q09. |Which function returns the sum of all elements of a list?
ja) count() b) sum() c) total() d) addQ)
Ans {Sum()
{Q10. |Assertion (A): To use a function from a particular module, we need to import}
hat module.
[Reasoning (R): import statement can be written anywhere in the program,
before using a function from that module.
[Ans ja) Both (A) and (R) are True and (R) is the correct explanation for (A)
]Q11. [State True or False.
* Tuple is a datatype in python which contain data in key — value pair”
Ans |FALSE
{Q12. |Which of the following is not a keyword?
a) eval b) assert c) nonlocal d) pass
[Ans |a) eval
\Q13. (Consider the given expression.
not ( ( True and False ) or True )
hich of the following will be the correct output, if the given expression is
evaluated?
a) True b) False c) NONE d) NULL
[Ans |b) Falseaia.
|Given the following dictionaries
\dict_student = {"rmo" : "53", "name" : ‘Rajveer Singh’}
lict_marks = {"Accts" : 87, "English" : 65}
Which statement will merge the contents of both dictionaries?
(A) dict_student + dict_marks (B)
dict_student.add(dict_marks)
(C) dict_student.merge(dict_marks) (D)
dict_student.update(dict_marks)
(D) dict_student.update(dict_marks)
jQ15.
Select the correct output of the code:
s='mail2kv @[Link]'
s=[Link](‘kv')
op = s[0] +"@kv" + s[2]
print(op)
(A) mail2 @kvsangathan (B) mail2@sangathan.
(C) mail2@kvsangathan. (D) mail2kvsangathan.
\Ans
(C) mail2 @kvsangathan.
\Q16.
hich of the following statement(s) would give an error after executing the
following code?
ID={'rno':32,'name':'Ms
(Archana','subject’:[‘hindi’,'english’,'cs'],'marks':(85,75,89)} #S1 print(D)
H#S2
ID['subject'][2]="IP' #83
D['marks'][2]=80 #S4
print(D) #85
A) SI (B) S3 (C) S4 (D) S3 and S4
C) S4
\Q17.
hhat will the following expression be evaluated to in Python?
print (round (100.0/4 + (3 + 2.55), 1))
A) 30.0 (B) 30.55 (©) 30.6 (D) 31
|Ans
C) 30.6ais.
tr1= “Class” + Work”
ASSERTION: Value of str1 will be “ClassWork”
IREASONING: Operator ‘+’ adds the operands, if both are numbers &
\concatenates the string if both operands are strings.
[Ans (A) Both A and R are true and R is the correct explanation for A
Q19. peate True or False
“Python has a set of keywords that can also be used to declare variables”
Ans |FALSE
|Q20. [Which of the following is not a valid python operator?
la) % b) in c)# d)**
[Ans k)#
|Q21. |What will be the output of the following python dictionary operation?
\data = {'A':2000, 'B':2500, 'C':3000, 'A':4000}
print(data)
fa) {'A':2000, 'B':2500, 'C':3000, 'A':4000}
ib) {'A':2000, 'B':2500, 'C':3000}
c) {'A':4000, 'B':2500, 'C':3000}
!) It will generate an error.
Ans _{) {'A':4000, 'B':2500, 'C':3000}
{Q22. | print(True or not True and False)
{Choose one option from the following that will be the correct output after
executing the above python expression.
) False b) True c)or d) not
[Ans |b) True
{Q23. Select the correct output of the following python code:
tr="My program is program for you"
= [Link]("program")
iprint(t)
fa) (My ', ‘program’ ', ‘program’, ' for you’)
ib) (‘My ', ‘program’, ' is program for you')
ic) (My ', ‘is program for you’)
\@) (My','is',' for you')
l[Ans_ |b) (‘My ', ‘program’, ' is program for you’)