Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python lesson 1 to 5 编程测验

Total questions: 79

Worksheet time: 40mins

Name
Class
Date
1.

Python 是什么类型的编程语言?

a)

汇编语言

b)

机器语言

c)

低级编程语言

d)

高级编程语言

2.

Python 的开发者是谁?

a)

Linus Torvalds

b)

Bjarne Stroustrup

c)

Guido van Rossum

d)

James Gosling

3.

以下哪个是 Python 的特点?

a)

复杂难学

b)

收费软件

c)

不支持社区

d)

跨平台运行

4.

Python 可以用于哪些领域?

a)

网站开发

b)

以上所有

c)

数据分析

d)

人工智能

5.

如何在 Python 中输出字符串?

a)

output('Hello')

b)

echo 'Hello'

c)

print('Hello')

d)

write('Hello')

6.

在 Python 中,字符串必须放在什么符号里?

a)

大括号

b)

方括号

c)

括号

d)

引号

7.

以下哪个是有效的 Python 输出语句?

a)

print('Hello)

b)

print(Hello')

c)

print('Hello')

d)

print(Hello)

8.

在 Python 中,如何表示换行?

a)

\r

b)

\t

c)

\b

d)

\n

9.

Python 中的整数类型用什么表示?

a)

int

b)

float

c)

str

d)

bool

10.

Python 中的浮点数用什么表示?

a)

float

b)

list

c)

str

d)

int

11.

在 Python 中,布尔值的两个可能值是什么?

a)

True 和 False

b)

1 和 0

c)

是 和 否

d)

高 和 低

12.

Python 中的列表 list 用什么符号表示?

a)

{}

b)

()

c)

[]

d)

<>

13.

Python 中的字典 dictionary 用什么符号表示?

a)

{}

b)

[]

c)

()

d)

<>

14.

在 Python 中,如何查看变量的类型?

a)

checktype()

b)

var_type()

c)

type()

d)

typeof()

15.

在 Python 中,如何将字符串转换为整数?

a)

int()

b)

str()

c)

float()

d)

bool()

16.

在 Python 中,如何使用 f-string 格式化字符串?

a)

print(f'Hello')

b)

print(f'Hello)

c)

print('Hello')

d)

print(Hello')

17.

Python 中的运算符优先级从高到低的顺序是什么?

a)

() > + - > * / > **

b)

+ - > * / > ** > ()

c)

** > * / > + - > ()

d)

() > ** > * / > + -

18.

在 Python 中,if 语句的基本结构是什么?

a)

if condition:

b)

if condition {}

c)

if (condition) {}

d)

if condition;

19.

在 Python 中,else 语句的作用是什么?

a)

处理异常

b)

处理循环

c)

处理条件成立的情况

d)

处理其他情况

20.

在 Python 中,elif 语句的作用是什么?

a)

处理多个条件

b)

处理单一条件

c)

处理异常

d)

处理循环

21.

在 Python 中,如何判断一个数字是否为偶数?

a)

if num % 2 == 0:

b)

if num / 2 == 0:

c)

if num % 2 != 0:

d)

if num // 2 == 0:

22.

在 Python 中,如何让用户输入信息?

a)

read()

b)

input()

c)

scan()

d)

get()

23.

在 Python 中,如何将用户输入的字符串转换为整数?

a)

int(input())

b)

str(input())

c)

float(input())

d)

bool(input())

24.

在 Python 中,如何使用逻辑运算符 and?

a)

if a and b:

b)

if a && b:

c)

if a & b:

d)

if a and b;

25.

在 Python 中,如何使用逻辑运算符 or?

a)

if a || b:

b)

if a | b:

c)

if a or b;

d)

if a or b:

26.

在 Python 中,如何使用逻辑运算符 not?

a)

if not a:

b)

if not a;

c)

if !a:

d)

if ~a:

27.

在 Python 中,如何处理嵌套条件判断?

a)

在 else 内再写 if

b)

在 if 内再写 if

c)

在 elif 内再写 if

d)

以上都对

28.

在 Python 中,如何使用 pass 占位?

a)

if condition:

b)

if (condition) pass

c)

if condition: pass

d)

if condition; pass

29.

x = 10

if x > 5:

print("A")

if x > 8:

print("B")

else:

print("C")

这段代码的输出是什么?

a)

A B

b)

A C

c)

B C

d)

A B C

30.

pass语句的目的是什么?

a)

终止程序

b)

跳过当前迭代

c)

作为空代码块的占位符

d)

打印消息

31.

(3 + 2) * 4 > 15 or not False的结果是什么?

a)

True

b)

False

c)

错误

d)

None

32.
Python是谁创建的?
a)
比尔·盖茨
b)
吉多·范罗苏姆
c)
马克·扎克伯格
d)
史蒂夫·乔布斯
33.
Python首次发布于哪一年?
a)
1985
b)
1991
c)
2000
d)
1995
34.
Python的口号是什么?
a)
只管去做
b)
不同凡想
c)
写得少,做得多
d)
容易学习
35.
以下哪项不是Python的特点?
a)
简单易学
b)
免费开源
c)
只能在Windows上运行
d)
有庞大的社区
36.
在Python中打印'Hello World'的正确方式是什么?
a)
print(Hello World)
b)
print("Hello World")
c)
print 'Hello World'
d)
print[Hello World]
37.
字符串中的\n字符有什么作用?
a)
创建新行
b)
添加空格
c)
打印反斜杠
d)
使文本加粗
38.
print("Python" * 3)会输出什么?
a)
PythonPythonPython
b)
Python 3
c)
PythonPython
d)
错误
39.
Python中使用什么符号表示注释?
a)
//
b)
#
c)
/*
d)
--
40.
编程中的变量是什么?
a)
数学方程
b)
存储数据的容器
c)
一种函数类型
d)
条件语句
41.
以下哪个不是有效的Python变量名?
a)
my_var
b)
1var
c)
var_name
d)
_var
42.
Python会将x = 5分配为什么数据类型?
a)
浮点数
b)
整数
c)
字符串
d)
布尔值
43.
Python会将x = 3.14分配为什么数据类型?
a)
浮点数
b)
整数
c)
字符串
d)
布尔值
44.
Python会将x = "Hello"分配为什么数据类型?
a)
浮点数
b)
整数
c)
字符串
d)
布尔值
45.
Python会将x = True分配为什么数据类型?
a)
浮点数
b)
整数
c)
字符串
d)
布尔值
46.
Python中使用什么符号创建列表?
a)
{}
b)
[]
c)
()
d)
<>
47.
Python中使用什么符号创建元组?
a)
{}
b)
[]
c)
()
d)
<>
48.
Python中使用什么符号创建字典?
a)
{}
b)
[]
c)
()
d)
<>
49.
print(type("Hello"))会输出什么?
a)
<class 'int'>
b)
<class 'float'>
c)
<class 'str'>
d)
<class 'bool'>
50.
如何将x = "5"转换为整数?
a)
int(x)
b)
str(x)
c)
float(x)
d)
bool(x)
51.
使用f-string打印"My name is Ali and I am 16"的正确语法是什么?
a)
print("My name is {name} and I am {age}")
b)
print(f"My name is {name} and I am {age}")
c)
print("My name is " + name + " and I am " + age)
d)
print(f"My name is name and I am age")
52.
input()函数总是返回什么?
a)
整数
b)
浮点数
c)
字符串
d)
布尔值
53.
如何从用户获取整数输入?
a)
int(input())
b)
input(int)
c)
input().int()
d)
int.input()
54.

name = input("你叫什么名字? ")

print("你好", name),

如果用户输入"Ali":

a)

你好. Ali

b)
你好,Ali
c)
你好 Ali
d)
错误
55.
以下哪个是有效的Python变量名?
a)
1st_name
b)
first-name
c)
first_name
d)
first name
56.
以下哪个不是Python关键字?
a)
if
b)
while
c)
print
d)

name

57.
print(keyword.iskeyword("if"))会输出什么?
a)
True
b)
False
c)
错误
d)
None
58.
%运算符有什么作用?
a)
除法
b)
乘法
c)

取余数

d)
幂运算
59.
**运算符有什么作用?
a)
除法
b)
乘法
c)
取模
d)
幂运算
60.
5 == 5的结果是什么?
a)
True
b)
False
c)
1
d)
0
61.
5 != 5的结果是什么?
a)
True
b)
False
c)
1
d)
0
62.
True and False的结果是什么?
a)
True
b)
False
c)
错误
d)
None
63.
True or False的结果是什么?
a)
True
b)
False
c)
错误
d)
None
64.
not True的结果是什么?
a)
True
b)
False
c)
错误
d)
None
65.
Python中运算符的正确优先级顺序是什么?
a)
() > ** > * / > + - > 比较 > not > and > or
b)
** > () > * / > + - > 比较 > and > or > not
c)
* / > () > ** > + - > 比较 > not > and > or
d)
() > * / > ** > + - > 比较 > or > and > not
66.
(3 + 2) * 4 > 15 or not False的结果是什么?
a)
True
b)
False
c)
错误
d)
None
67.
Python中使用什么来表示代码块?
a)
大括号{}
b)
缩进
c)
圆括号()
d)
方括号[]
68.

if x > 5

print('大')

缺少什么?

a)
条件周围的圆括号
b)
条件后的冒号
c)
代码块的大括号
d)
什么都不缺
69.

age = 15

if age >= 18:

print('成人')

else:

print('未成年人')

输出?

a)
成人
b)
未成年人
c)
错误
d)
None
70.

score = 75

if score >= 80:

print('优秀')

elif score >= 60:

print('及格')

else:

print('不及格')

输出?

a)
优秀
b)
及格
c)
不及格
d)
错误
71.

x = 5

if x > 3:

pass

else:

print('x <= 3')

输出?

a)
x > 3
b)
x <= 3
c)
无输出
d)
错误
72.

if x = 5:

print('五')

有什么问题?

a)
缺少冒号
b)
使用=而不是==
c)
缺少圆括号
d)
没有问题
73.
如何检查一个数字是否在10到20之间?
a)
if 10 < x < 20:
b)
if x > 10 and x < 20:
c)
if x in range(10, 20):
d)
以上都是
74.

age = 16

if age >= 13 and age < 18:

print('青少年')

输出?

a)
青少年
b)
无输出
c)
错误
d)
True
75.

x = 5

if x > 0:

if x > 3:

print('大')

else:

print('小')

else:

print('负数')

输出?

a)
大
b)
小
c)
负数
d)
错误
76.
检查数字是否为偶数的正确方式是什么?
a)
if number % 2 == 0:
b)
if number / 2 == 0:
c)
if number // 2 == 0:
d)
if number * 2 == 0:
77.

age = int(input('输入年龄:'))

if age >= 18:

print('欢迎')

else:

print('不允许')

若输入16 输出?

a)
欢迎
b)
不允许
c)
错误
d)
None
78.
Python中elif的目的是什么?
a)
创建一个新的if语句
b)
如果前面的条件为假,则检查另一个条件
c)
结束一个if语句
d)
组合多个条件
79.

x = 5

if not x > 10:

print('OK')

输出?

a)
OK
b)
无输出
c)
错误
d)
True