2020 Python程序设计语言(南昌工程学院) 最新满分章节测试答案
本答案对应课程为:点我自动跳转查看
本课程起止时间为:2020-02-17到2020-07-10
本篇答案更新状态:已完结
【作业】MODULE 01: Python基础之第二周 Python面面观 控制结构和函数编程题
1、 问题:寻找n以内的亲密数对。
代码格式如下:
def fac(n):
…
return xxx
n = int(input()) # 此处输入由系统自动完成不需要自己输入,只要写这样一条语句即可
…
建议:【本题是主观题,暂无解析】
2、 问题:寻找第n个默尼森数。
代码格式如下:
def prime(num):
…
def monisen(no):
… …
return xxx
print(monisen(int(input()))) # 此处输入由系统自动完成不需要自己输入,只要写这样一条语句即可
建议:【本题是主观题,暂无解析】
MODULE 01: Python基础之第二周 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):
s = 1
while n > 0:
n -= 1
s = s * x
return s分别对该函数传递参数,调用my_power(-3)和my_power(3, 3)后运行结果分别是什么?
选项:
A:9和27
B:-9和27
C:9和-27
D:-9和-27
答案: 【9和27】
7、 问题:执行以下代码会产生哪一种异常?>>> a = 3
>>> print(a ** b)
选项:
A:IndexError
B:ValueError
C:TypeError
D:NameError
答案: 【NameError】
8、 问题:已知有如下代码:>>> import random
>>> random.______()执行后产生的随机数始终在[0, 1.0)之间,请问它可能是random库中的哪一个函数?
选项:
A:randint
B:random
C:uniform
D:shuffle
答案: 【random】
9、 问题:以下关于Python的函数执行控制判断说法中正确的有哪些?
选项:
本文章不含期末不含主观题!!
本文章不含期末不含主观题!!
支付后可长期查看
有疑问请添加客服QQ 2356025045反馈
如遇卡顿看不了请换个浏览器即可打开
请看清楚了再购买哦,电子资源购买后不支持退款哦