Home  >  Article  >  Backend Development  >  What are the simple test questions for Python?

What are the simple test questions for Python?

WBOY
WBOYforward
2023-05-01 18:49:131511browse

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. 456

4 The output of the following code is:

print([1, 2] == [(1), (2)])
print([1, 2] == [(1,), (2,)])

A.True True

B.True False

C.False True

D.False False

5 The output result of the following code is:

print('hi') if 3 > 4 else print('bye')

A. Error report

B.hi

C.bye

D.hi bye

6 The output result of the following code is:

num = 6 if True == 1.0 else 8
print(num)

A. Error report

B.6

C.8

D.True

7 The output of the following code is:

for i in range(5):
    pass
print(i)

A .Error

B.None

C.4

D.5

8 The output of the following code is:

alist = [1, 2, 3]
blist = [i ** 2 for i in alist]
print(i)

A. Error

B.None

C.3

D.9

9 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 tuple

C. No error will be reported if [1,2] is changed to a set

D .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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete