在线看高清免费av|亚洲一级AAAAAA|亚洲黄色三级av在线小说|国产电影黄色无码,免费|尤物视频成人亚洲激情有码网|91人人尤物视频|欧美一级特黄色大片|久草九草黄色视频大片|操操操操操操操|国产69精品久久久久男男系列
Python分支結(jié)構(gòu)
本次考試旨在考察高中學生對Python選擇結(jié)構(gòu)知識的掌握情況,請認真作答。
1. 考生基本信息
姓名:
2. 以下哪個不是Python中的條件判斷關(guān)鍵字?
if
else
elif
switch
3. 在Python中,以下哪個符號用于表示不等于?
=
==
!=
<>
4. 執(zhí)行語句if 5 > 3: print('yes') else: print('no'),輸出結(jié)果是?
yes
no
5>3
報錯
5. 以下代碼的輸出結(jié)果是?
a = 10
if a > 15:
print('A')
elif a > 5:
print('B')
else:
print('C')
A
B
C
無輸出
6. Python中,if語句的條件表達式的結(jié)果最終被解析為:
整數(shù)
字符串
布爾值
任意類型
7. 以下代碼的輸出結(jié)果是?
x = 3
y = 5
if x > y:
print(x)
else:
print(y)
3
5
x
y
8. 以下哪個代碼段可以正確判斷一個數(shù)是否為偶數(shù)?
if num % 2 = 0:
if num % 2 == 0:
if num / 2 == 0:
if num // 2 == 0:
9. 在if-elif-else結(jié)構(gòu)中,else的位置是?
必須在所有if之后
必須在所有elif之后
可以在任意位置
可以省略
10. 以下代碼的輸出結(jié)果是?
score = 85
if score >= 90:
grade = 'A'
elif score >= 80:
grade = 'B'
elif score >= 70:
grade = 'C'
else:
grade = 'D'
print(grade)
A
B
C
D
11. 以下哪個表達式的值為True?
3 > 5 or 4 > 2
3 > 5 and 4 > 2
3 > 5
not (4 > 2)
12. Python中,邏輯與運算符是?
&
&&
and
AND
13. 以下代碼的輸出結(jié)果是?
a = 5
b = 5
if a is b:
print('equal')
else:
print('not equal')
equal
not equal
報錯
不確定
14. 執(zhí)行以下代碼后,變量x的值是?
x = 1
if x > 0:
x = x + 1
if x > 1:
x = x + 1
1
2
3
4
15. 以下代碼的輸出結(jié)果是?
num = 3
if num % 2 == 0:
print('even')
if num % 3 == 0:
print('multiple of 3')
even
multiple of 3
even multiple of 3
無輸出
16. Python中,用于多條件判斷的結(jié)構(gòu)是?
if...else...
if...elif...else...
switch...case...
以上都可以
17. 以下代碼的輸出結(jié)果是?
flag = False
if flag:
print('Hello')
else:
pass
Hello
pass
無輸出
報錯
18. 以下代碼的輸出結(jié)果是?
a = 10
b = 20
if a > b:
print(a - b)
else:
print(b - a)
-10
10
30
0
19. 以下代碼的輸出結(jié)果是?
x = 7
if x % 2 == 1:
print('odd')
else:
print('even')
odd
even
7
2
20. 在if語句中,縮進的作用是?
美觀
區(qū)分代碼塊
必須的,否則報錯
沒有實際作用
21. 以下代碼的輸出結(jié)果是?
name = 'Alice'
if name == 'Bob':
print('Hi Bob')
elif name == 'Alice':
print('Hi Alice')
else:
print('Hi stranger')
Hi Bob
Hi Alice
Hi stranger
無輸出
22. 以下哪個代碼段會輸出'OK'?
if True: print('OK')
if 0: print('OK')
if '': print('OK')
if None: print('OK')
23. 以下代碼的輸出結(jié)果是?
age = 15
if age >= 18:
print('adult')
else:
print('minor')
adult
minor
15
18
24. 以下哪個是Python中的條件表達式(三元運算符)的正確格式?
條件 ? 表達式1 : 表達式2
表達式1 if 條件 else 表達式2
if 條件 then 表達式1 else 表達式2
條件 if 表達式1 else 表達式2
25. 執(zhí)行以下代碼后,變量y的值是?
x = 5
y = 10 if x > 3 else 20
5
10
20
3
26. 以下代碼的輸出結(jié)果是?
a = 3
b = 4
c = 5
if a + b > c and a + c > b and b + c > a:
print('triangle')
else:
print('not triangle')
triangle
not triangle
3+4>5
報錯
27. 以下代碼的輸出結(jié)果是?
num = 0
if num:
print('positive')
elif num == 0:
print('zero')
else:
print('negative')
positive
zero
negative
無輸出
28. 以下哪個代碼段會輸出'Good morning'?
time = 8 if time < 12: print('Good morning')
time = 14 if time < 12: print('Good morning')
time = 12 if time < 12: print('Good morning')
time = 10 if time > 12: print('Good morning')
29. 以下代碼的輸出結(jié)果是?
x = 2
y = 3
if x * y > 5:
print(x * y)
else:
print(x + y)
5
6
2
3
30. 以下代碼的輸出結(jié)果是?
score = 59
f score >= 60:
print('pass')
else:
print('fail')
pass
fail
59
60
31. 以下哪個表達式不會報錯且結(jié)果為True的是:
'a' > 'b'
'apple' < 'banana'
10 < '10'
[1,2] > [1,3]
32. 執(zhí)行以下代碼后,變量result的值是?
result = 'A' if 4 > 5 else 'B'
A
B
4
5
33. 以下代碼的輸出結(jié)果是?
a = True
b = False
if a or b:
print('True')
else:
print('False')
True
False
a or b
報錯
34. 以下哪個代碼段會輸出'Both conditions are true'?
x = 5 if x > 0 and x < 10: print('Both conditions are true')
x = -1 if x > 0 and x < 10: print('Both conditions are true')
x = 15 if x > 0 and x < 10: print('Both conditions are true')
x = 0 if x > 0 and x < 10: print('Both conditions are true')
35. Python中,if語句可以嵌套使用,嵌套的縮進要求是?
必須比外層多縮進
必須和外層一樣縮進
可以隨意縮進
不能嵌套
36. 以下代碼的輸出結(jié)果是?
x = 10
if x > 5:
if x > 15:
print('A')
else:
print('B')
else:
print('C')
A
B
C
無輸出
關(guān)閉
更多問卷
復制此問卷