第二周数据类型、运算符与表达式、变量赋值与简单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、单选题:
‏执行下列语句,输出的结果是?x = 7.0
y = 5
print x % y‌
选项:
A: 2.0
B: 2
C: 程序出错
D: 1
E: 1.0
答案: 【 2.0

2、单选题:
‍能实现下面功能的程序是?接收用户输入的一个整数。如果输入的是偶数,则输出“True”,否则输出“False”。‏
选项:
A: print not bool(int(raw_input()) % 2)
B: print int(raw_input()) % 2 == 0
C: print int(raw_input()) % 2 != 0
D: print bool(int(raw_input()) % 2)
E: print not bool(raw_input() % 2)
F: print int(raw_input()) % 2 == 1
答案: 【 print not bool(int(raw_input()) % 2);
print int(raw_input()) % 2 == 0

3、填空题:
假设你每年初往银行账户中1000元钱,银行的年利率为4.7%。‍一年后,你的账户余额为:‍1000 * ( 1 + 0.047) = 1047 元‍第二年初你又存入1000元,则两年后账户余额为:‍(1047 + 1000) * ( 1 + 0.047) = 2143.209 元‍以此类推,第10年年末,你的账户上有多少余额?‍注:结果保留2位小数(四舍五入)。‍
答案: 【 12986.11

4、填空题:
‌Python提供了众多的模块。你能找到一个合适的模块,输出今天的日期吗?格式为“yyyy-mm-dd”。可以查找任何搜索引擎和参考资料,并在下面的空白处写出相应的模块名。‍
答案: 【 datetime##%_YZPRLFH_%##time##%_YZPRLFH_%##calendar

5、填空题:

​对于一元二次方程,若有 ,则其解是什么?若有多个解,则按照从小到大的顺序在一行中输出,中间使用空格分隔。解保留2位小数(四舍五入)。

‌答案: 【 -3.58 -0.42

第三周程序控制结构

测验1

1、判断题:
下列求100以内所有偶数之和的程序是否正确?​sum = 0
i = 0
while i < 100:
    if i % 2 == 0:
        sum += i
        i += 2
print sum​‌​
选项:
A: 正确
B: 错误
答案: 【 正确

2、判断题:
下列求100以内所有奇数之和的程序是否正确?‍sum = 0
i = 1
while sum < 100:

剩余75%内容付费后可查看

发表评论

电子邮件地址不会被公开。 必填项已用*标注