Online Training Exam Details
Online Training Exam Details
Online Training Exam Details
1 B B
sample_dict={'a':1,'b':2}
sample_dict.update({'b':5, 'c':10 })
print(sample_dict.get('a'),sample_dict.get('b'),sample_dict.get('c'))
a) None 5 10
b) 1 5 10
c) 1 2 None
d) 1 5 None
2 B B
https://erp.psit.ac.in/Student/OnlineTrainingDetails/3f3a8af563d88b40a2f41b94851029ad9493d85c6d7d25515233b6717cde34c2633b2920af546671… 1/12
12/26/22, 3:58 PM PSIT
message="welcome to Mysore"
word=message[-7:]
if(word=="mysore"):
print("got it")
else:
message=message[3:14]
print(message)
a) got it
b) come to Mys
c) come to Myso
d) lcome to Mys
3 D D
4 C C
5 A A
https://erp.psit.ac.in/Student/OnlineTrainingDetails/3f3a8af563d88b40a2f41b94851029ad9493d85c6d7d25515233b6717cde34c2633b2920af546671… 2/12
12/26/22, 3:58 PM PSIT
6 B B
import itertools
l1=(1, 2, 3)
l2=[4, 5, 6]
l=itertools.chain(l1, l2)
print(next(l1))
a) ‘list’ object is not iterator
b) ‘tuple’ object is not iterator
c) ‘list’ object is iterator
d) ‘tuple’ object is iterator
7 C C
8 B B
https://erp.psit.ac.in/Student/OnlineTrainingDetails/3f3a8af563d88b40a2f41b94851029ad9493d85c6d7d25515233b6717cde34c2633b2920af546671… 3/12
12/26/22, 3:58 PM PSIT
9 D D
10 A A
11 A A
a = 20
b = 30
assert b - a , 'a is smaller than b'
print(b)
a)30
b)20
c)10
d)Assertion Error:a is smaller than b
12 A A
13 B B
https://erp.psit.ac.in/Student/OnlineTrainingDetails/3f3a8af563d88b40a2f41b94851029ad9493d85c6d7d25515233b6717cde34c2633b2920af546671… 4/12
12/26/22, 3:58 PM PSIT
14 A A
try:
if '2' != 2:
raise ValueError
else:
print('same')
except ValueError:
print('ValueError')
except NameError:
print('NameError')
a)Value Error
b)Name Error
c)same
d)None of the above
15 D D
try:
print('try')
except ValueError:
print('ValueError')
finally:
print('finally')
a)try
b)finally
c)Value Error
d)try finally
16 B B
https://erp.psit.ac.in/Student/OnlineTrainingDetails/3f3a8af563d88b40a2f41b94851029ad9493d85c6d7d25515233b6717cde34c2633b2920af546671… 5/12
12/26/22, 3:58 PM PSIT
17 C C
18 D D
19 B B
20 B B
https://erp.psit.ac.in/Student/OnlineTrainingDetails/3f3a8af563d88b40a2f41b94851029ad9493d85c6d7d25515233b6717cde34c2633b2920af546671… 6/12
12/26/22, 3:58 PM PSIT
21 A A
def doThis():
global count
doThis()
print (count)
A)4
B)3
C)2
D)0
22 C C
23 D D
https://erp.psit.ac.in/Student/OnlineTrainingDetails/3f3a8af563d88b40a2f41b94851029ad9493d85c6d7d25515233b6717cde34c2633b2920af546671… 7/12
12/26/22, 3:58 PM PSIT
A. >>>'TSET NOHTY'
B.>>> 'PYTHON TES'
C.>>> PYTHON TEST
D.None of the above
24 A A
def addToCounter(country):
if country in counter:
counter[country] += 1
else:
counter[country] = 1
addToCounter('China')
addToCounter('Japan')
addToCounter('china')
print (len(counter))
A)3
B)2
C)1
D)0
25 A A
A. 87654321
B. 12345678
C. NameError
D. TypeError
26 C C
https://erp.psit.ac.in/Student/OnlineTrainingDetails/3f3a8af563d88b40a2f41b94851029ad9493d85c6d7d25515233b6717cde34c2633b2920af546671… 8/12
12/26/22, 3:58 PM PSIT
A. Error
B. prints nothing
C. helloworld
D. 0
27 B B
A. PYTHO TEST
B. PYTHON TEST
C. PYTHONTEST
D. Error
28 C C
29 B B
https://erp.psit.ac.in/Student/OnlineTrainingDetails/3f3a8af563d88b40a2f41b94851029ad9493d85c6d7d25515233b6717cde34c2633b2920af546671… 9/12
12/26/22, 3:58 PM PSIT
30 A A
Assuming that there is a file 'data.txt' in current directory, what will be the output of the following Python code?
f = None
for i in range(5):
if i > 2:
break
f.close()
A. Entire contents of the file are displayed
B. Only two lines of the file are displayed
C. Only 3 lines of the file are displayed
D. Error
31 A A
32 A A
A. TypeError
B. myfile.txt now contains "12460"
C. myfile.txt now contains 12460
D. gives warning and writes the content
33 C C
https://erp.psit.ac.in/Student/OnlineTrainingDetails/3f3a8af563d88b40a2f41b94851029ad9493d85c6d7d25515233b6717cde34c2633b2920af54667… 10/12
12/26/22, 3:58 PM PSIT
A. Runtime Error
B. Hello World how are you today
C. returns a list of one character on each line
D. Hello
34 C C
35 D D
https://erp.psit.ac.in/Student/OnlineTrainingDetails/3f3a8af563d88b40a2f41b94851029ad9493d85c6d7d25515233b6717cde34c2633b2920af54667… 11/12
12/26/22, 3:58 PM PSIT
https://erp.psit.ac.in/Student/OnlineTrainingDetails/3f3a8af563d88b40a2f41b94851029ad9493d85c6d7d25515233b6717cde34c2633b2920af54667… 12/12