wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python03条件判断

Total questions: 67

Worksheet time: 23mins

Name
Class
Date
1.
在python中,要在输出区打印内容,需要使用什么命令?
a)
print
b)
input
c)
range
d)
for
2.
字符串是由一对引号包裹的内容。下列哪个不是字符串?
a)
'abc'
b)
'123'
c)
abc
d)
'我爱你'
3.
下面哪一条语句能打印出数字10?
a)
print("10")
b)
print(10)
c)
print('十')
d)
print("ten")
4.
下列选项中,哪一个是正确的变量命名?
a)
2cat
b)
cat_1
c)
my-cat
d)
my cat
5.

下面哪一条语句可以打印出计算结果的数字20?

a)
print("10+10")
b)
print(10+10)
c)
print('20')
d)
print("20")
6.
for i in range(3): i 的取值顺序是?
a)
1 2 3
b)
0 1 2
c)
2 3 4
d)
1 3 5
7.
执行 for i in range(2,6): print(i),输出结果是?
a)
2 3 4 5
b)
1 2 3 4
c)
2 4 6 8
d)
3 4 5 6
8.
下列哪一条语句可以打印出字符串 hello?
a)
print(hello)
b)
print("hello")
c)
print(hello")
d)
print('hello)
9.
如果执行 a=5 和 b='5',下列说法正确的是?
a)
两个都是整数
b)
两个都是字符串
c)
a是整数b是字符串
d)
a是字符串b是整数
10.
print(80/(2*2)) 的结果是?
a)
10
b)
20
c)
40
d)
80
11.
for i in range(5,0,-2): i 的取值顺序是?
a)
5 3 1
b)
1 3 5
c)
5 4 3 2 1
d)
4 2
12.
下面哪一条语句通过拼接的方式输出AB(没有空格或其他字符)?
a)
print("A,B")
b)
print("A"+"B")
c)
print("AB")
d)
print("A B")
13.
变量 a=10,执行 a=a+5 后,a 的值是?
a)
5
b)
10
c)
15
d)
20
14.
执行 print("3*4") 的结果是?
a)
3*4
b)
12
c)
三乘四
d)
结果是12
15.
执行 print(3*4) 的结果是?
a)
3*4
b)
12
c)
三乘四
d)
结果是12
16.
如果要让用户输入名字并存入变量 name,应使用哪条语句?
a)
name=print()
b)
name=input()
c)
name==input()
d)
input=name
17.
若执行 print(len("Python")),结果是?
a)
5
b)
6
c)
7
d)
8
18.
print("A"*3) 的输出结果是?
a)
AAA
b)
A A A
c)
3A
d)
A3
19.
下列哪一条语句可以正确输出 Hello World?
a)
print("Hello World")
b)
print('Hello World')
c)
print(Hello World)
d)
print("Hello,World")
20.
如果变量 x=8,下列哪条语句判断 x 等于 8?
a)
if x=8
b)
if x==8
c)
if (x=8)
d)
if x!=8
21.
执行 if 5>3: print("Yes"),输出是什么?
a)
No
b)
Yes
c)
True
d)
False
22.
如果条件不成立,if 语句会怎样?
a)
依然执行
b)
跳过不执行
c)
显示错误
d)
重复执行
23.
下面关于 if 语句的说法正确的是?
a)
必须有 else
b)
必须有冒号
c)
必须有大括号
d)
不能嵌套
24.
执行 if 10<5: print("A") print("B"),会输出什么?
a)
A
b)
B
c)
A B
d)
没有输出
25.
执行 if "a"=="a": print("same"),输出是什么?
a)
不同
b)
一样
c)
same
d)
True
26.
执行 if 7==7: print("ok"),输出是什么?
a)
ok
b)
不输出
c)
True
d)
7
27.
如果 a=3,下列哪条语句条件为真?
a)
if a>5
b)
if a<3
c)
if a==3
d)
if a!=3
28.
下面哪一条语句语法错误?
a)
if a=5: print(a)
b)
if a==5: print(a)
c)
if a>3: print(a)
d)
if a!=2: print(a)
29.
当 if 条件为假时,程序会?
a)
停止运行
b)
执行 else
c)
什么也不做
d)
打印错误
30.
若执行 for i in range(1,4): print(i),会输出哪些数字?
a)
0 1 2
b)
1 2 3
c)
2 3 4
d)
1 3 5
31.
在 for 循环中,range(2,10,3) 生成的数字是?
a)
2 3 4 5 6
b)
2 5 8
c)
2 6 9
d)
3 6 9
32.
执行 s="abc",print(s*2) 的结果是?
a)
abc2
b)
abcabc
c)
aabbcc
d)
2abc
33.
下面关于变量的描述正确的是?
a)
变量名可以有空格
b)
变量可以存数字
c)
变量不能存字符串
d)
变量必须以数字开头
34.
input() 的作用是?
a)
输出文字
b)
结束程序
c)
接收输入
d)
定义变量
35.
执行 name=input("请输入姓名:"),用户输入 Tom,name 的值是?
a)
请输入姓名:
b)
Tom
c)
input
d)
姓名
36.
执行 if 8>2: print("Yes") else: print("No"),输出是什么?
a)
Yes
b)
No
c)
True
d)
False
37.
如果 light 的值是 "绿色",哪条语句可以打印前进?
a)
if light = "绿色": print("前进")
b)
if light == "绿色": print("前进")
c)
if light != "绿色": print("前进")
d)
if light > "绿色": print("前进")
38.

执行左图的代码会输出什么?

a)

A

优秀

^o^

b)

优秀

^o^

c)
^o^
d)

错误,无输出

39.

执行左图的代码会输出什么?

a)

A

优秀

^o^

b)

优秀

^o^

c)
^o^
d)

错误,无输出

40.
如果 n=16,执行 if n>50: print("A") if n<10: print("B"),输出是什么?
a)
A
b)
B
c)
AB
d)
没有输出
41.
执行 if "red"=="red": print("turn") print("turn"),会输出?
a)
turn
b)
turn turn
c)
red turn
d)
不输出
42.
执行 if 4!=5: print("OK"),会输出?
a)
错误
b)
不输出
c)
OK
d)
False
43.
执行 if 2>8: print("大") else: print("小"),输出是什么?
a)
b)
c)
错误
d)
True
44.
执行 if "A"!="B": print("不同"),输出是什么?
a)
相同
b)
不同
c)
True
d)
False
45.
执行 if 10>=10: print("Pass"),会输出?
a)
不输出
b)
错误
c)
Pass
d)
True
46.
执行 if 3<2: print("X") else: print("Y"),输出是什么?
a)
X
b)
Y
c)
不输出
d)
错误
47.
如果 a=7,执行 if a<5: print("小") else: print("大"),输出是什么?
a)
b)
c)
7
d)
不输出
48.
执行 if True: print("Yes") else: print("No"),输出是什么?
a)
Yes
b)
No
c)
True
d)
False
49.
执行 if False: print("A") else: print("B"),输出是什么?
a)
A
b)
B
c)
False
d)
不输出
50.
执行 if 9%2==1: print("奇数"),输出是什么?
a)
偶数
b)
奇数
c)
9
d)
不输出
51.
执行 if 6%2==0: print("偶数"),输出是什么?
a)
奇数
b)
偶数
c)
6
d)
False
52.
执行 if 5>2 and 8>3: print("Yes"),输出是什么?
a)
Yes
b)
No
c)
False
d)
不输出
53.
执行 if 5>10 or 3<4: print("Good"),输出是什么?
a)
Good
b)
No
c)
False
d)
不输出
54.
执行 if not 5>3: print("错") else: print("对"),输出是什么?
a)
b)
c)
不输出
d)
False
55.
执行 x=10 if x>0: print("正数") else: print("负数"),输出是什么?
a)
正数
b)
负数
c)
0
d)
不输出
56.
执行 age=18 if age>=18: print("成年") else: print("未成年"),输出是什么?
a)
未成年
b)
成年
c)
错误
d)
不输出
57.
执行 if "abc"=="ABC": print("same") else: print("diff"),输出是什么?
a)
same
b)
diff
c)
ABC
d)
abc
58.
执行 if "5"==5: print("相同") else: print("不同"),输出是什么?
a)
相同
b)
不同
c)
5
d)
5
59.
执行 if 0: print("有") else: print("无"),输出是什么?
a)
b)
c)
0
d)
False
60.
执行 if 1: print("真") else: print("假"),输出是什么?
a)
b)
c)
1
d)
False
61.
执行 if "": print("内容") else: print("空"),输出是什么?
a)
内容
b)
c)
""
d)
False
62.
执行 if len("hi")==2: print("OK"),输出是什么?
a)
OK
b)
不输出
c)
2
d)
hi
63.
执行 if len("python")>3: print("long") else: print("short"),输出是什么?
a)
long
b)
short
c)
python
d)
不输出
64.
执行 if "in" in "string": print("yes"),输出是什么?
a)
yes
b)
no
c)
in
d)
string
65.
执行 if "x" not in "apple": print("true"),输出是什么?
a)
True
b)
False
c)
x
d)
apple
66.
执行 if 7<10: print("A") print("B"),会输出?
a)
A B
b)
A
c)
B
d)
没有输出
67.
执行 if 10==10 and 5!=3: print("正确"),输出是什么?
a)
错误
b)
正确
c)
False
d)
不输出