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

What are the simple test questions for Python?

WBOY
Release: 2023-05-01 18:49:13
forward
1575 people have browsed it

1 The output of the following code is:

print(round(-3.6))
Copy after login

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())
Copy after login

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'])
Copy after login

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,)])
Copy after login

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')
Copy after login

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)
Copy after login

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)
Copy after login

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)
Copy after login

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]
Copy after login

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]})
Copy after login
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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template