Home > Article > Backend Development > What are the simple test questions for Python?
1 The output of the following code is:
print(round(-3.6))
A.-4
B.-4.0
C.- 3
D. -3.0
2 The output of the following code is (Python3.6 and above):
dic={ 'a':1,'b':4,'c':9,'xy':13} print(dic.popitem())
A.(‘a’:1,‘b’:4,‘c’:9)
B.(‘c’:9,‘xy’:13)
C.(‘a’,13)
D.(‘xy’,13)
##3 The output of the following code is:
adict = dict.fromkeys(['key1', 'key2'], []) adict['key1'].append(123) adict['key1'] = 456 print(adict['key2'])
A. Error B.[]C.[123]D. 4564 The output of the following code is:
print([1, 2] == [(1), (2)]) print([1, 2] == [(1,), (2,)])
A.True TrueB.True FalseC.False True5 The output result of the following code is:D.False False
print('hi') if 3 > 4 else print('bye')
A. Error reportB.hiC.byeD.hi bye6 The output result of the following code is:
num = 6 if True == 1.0 else 8 print(num)
A. Error reportB.6C.8D.True7 The output of the following code is:
for i in range(5): pass print(i)
A .Error B.NoneC.4D.58 The output of the following code is:
alist = [1, 2, 3] blist = [i ** 2 for i in alist] print(i)
A. Error B.NoneC.3D.99 After executing the following code After that, the value of blist is:
alist = [1, 2, 3] blist = [print(i+1) for i in alist]
A.[1,2,3]B.[2,3,4]C.[ None,None,None]D.[]10 The correct description of the following code is:
print({ 'a',[1,2]})
A. No error will be reported B. No error will be reported if [1,2] is changed to a tupleC. No error will be reported if [1,2] is changed to a setD .If you change [1,2] to a set, it will output {‘a’,1,2}
Answer: A D C B C B C A C B
The above is the detailed content of What are the simple test questions for Python?. For more information, please follow other related articles on the PHP Chinese website!