MOOC 计算机语言程序设计(深圳校区)(哈尔滨工业大学)1002585004 最新慕课完整章节测试答案
第一周程序设计的基础知识
测验3:下列代码运行时不会产生错误的是?
1、单选题:
下列代码运行时不会产生错误的是?
选项:
A: print 'Hi, I'm fine'
B: print "Hi, I'm fine"
C: print 'Hi, I'm fine"
D: print "Hi, I'm fine'
答案: 【 print "Hi, I'm fine"】
第二周数据类型、运算符与表达式、变量赋值与简单IO操作
测验1
1、单选题:
下列程序的执行结果为?x = 10
print type(x)
x = 10.0
print type(x)
x = '10.0'
print type(x)
选项:
A: <type 'int'>
<type 'float'>
<type 'str'>
B: <type 'int'>
<type 'int'>
<type 'int'>
C: <type 'str'>
<type 'str'>
<type 'str'>
D: 程序出错
答案: 【 <type 'int'>
<type 'float'>
<type 'str'>】
2、单选题:
若程序只有以下两行代码,则程序的执行结果为? x = y + 1
print x
选项:
A: 1
B: 输出一个随机值
C: 2
D: 程序出错
答案: 【 程序出错】
测验2
1、单选题:
执行下列语句,若输入为"HellonWorld",则输出为?input = raw_input()
print input
选项:
A: Hello World
B: Hello
C: HellonWorld
D: World
答案: 【 HellonWorld】
2、单选题:
执行下列语句,若输入为"123",则输出为?input = raw_input()
print input * 3
选项:
A: 369
B: 123123123
C: 1233
D: 程序出错
答案: 【 123123123】
测验3
1、判断题:
判断闰年的方式是否可以写成:y % 400 == 0 or y % 4 == 0 and y % 100 != 0
选项:
A: 正确
B: 错误
答案: 【 正确】
2、判断题:
判断闰年的方式是否可以写成:y % 4 == 0 and y % 100 != 0 or y % 400 == 0
选项:
A: 正确
B: 错误
答案: 【 正确】
第三周程序控制结构
测验1
1、判断题:
下列求100以内所有奇数之和的程序是否正确?sum = 0
i = 1
while sum < 100:
if i % 2 != 0:
sum += i
i += 2
print sum
选项:
A: 正确
B: 错误
答案: 【 错误】
2、判断题:
下列求100以内所有偶数之和的程序是否正确?sum = 0
i = 0
while i < 100:
if i % 2 == 0:
sum += i
i += 2
print sum
选项:
A: 正确
B: 错误
答案: 【 正确】
测验2
1、填空题:
下列代码的输出结果是?num = 9
count = 0
while num > 0:
if num % 2 == 0:
num /= 2
elif num % 3 =