大学MOOC Python程序设计语言(南昌工程学院)1450817196 最新慕课完整章节测试答案
MODULE01Python基础之第二周Python面面观
第二周Python面面观单元测试
1、单选题:
以下哪个语句可以打印出语句“rest apples are less than 9”且仅打印一次?
选项:
A: apples = 100
while True:
if apples < 9:
break
print("rest apples are less than 9")
apples -= 9
B: apples = 100
while True:
if apples < 9:
continue
print("rest apples are less than 9")
apples -= 9
C: apples = 100
while apples >= 1:
if apples < 9:
print("rest apples are less than 9")
break
apples -= 9
D: apples = 100
for a in reversed(xrange(apples)):
if a < 9:
print("rest apples are less than 9")
continue
apples -= 9
答案: 【 apples = 100
while apples >= 1:
if apples < 9:
print("rest apples are less than 9")
break
apples -= 9】
2、单选题:
对于函数def location(city, province):
# 字符串中%s对应输出字符串后%后的参数表中的参数值,其中s为字符串格式
print('%s belongs to %s province' % (city, province))以下哪一个语句的输出与其他几个不同?
选项:
A: location('Jiangsu', 'Nanjing')
B: location(province = 'Jiangsu', city = 'Nanjing')
C: location(city = 'Nanjing', province = 'Jiangsu')
D: location('Nanjing', 'Jiangsu')
答案: 【 location('Jiangsu', 'Nanjing')】
3、单选题:
定义以下函数,其中f为所需要传入的函数。def test(f, a, b):
print(f(a, b))则执行语句 test((lambda x,y: x ** 3 + y), 2, 3)的输出结果是哪个选项?
选项:
A: 8
B: 9
C: 10
D: 11
答案: 【 11】
4、单选题:
关于以下程序的正确说法是哪一项?def f(x):
a = 7
print(a + x)
a = 5
f(3)
print(a)
选项:
A: 程序的运行结果为10和7。
B: 程序的运行结果为10和5。
C: 程序的运行结果为8和5。
D: 程序不能正常执行。
答案: 【 程序的运行结果为10和5。】
5、单选题:
若k为整型,下述while循环执行的次数为多少次?k = 50
while k > 1:
print(k)
k = k // 2
选项:
A: 3
B: 4
C: 5
D: 6
答案: 【 5】
6、单选题:
定义函数如下:def my_power(x, n = 2):
