Coursera课程Python for everyone:chapter 2

Chapter 2

10 试题

1. 

Which of the following is a comment in Python?

# This is a test

* This is a test

/* This is a test */

// This is a test

2. 

What does the following code print out?

print "123" + "abc"

This is a syntax error because you cannot add strings

hello world

123+abc

123abc

3. 

Which of the following is a bad Python variable name?

Spam

_spam

SPAM23

23spam

4. 

Which of the following is not a Python reserved word?

iterate

continue

else

break

5. 

Assume the variable x has been initialized to an integer value (e.g., x = 3). What does the following statement do?

x = x + 2

This would fail as it is a syntax error

Exit the program

Increase the speed of the program by a factor of 2

Retrieve the current value for x, add two to it, and put the sum back into x

6. 

Which of the following elements of a mathematical expression in Python is evaluated first?

Parenthesis ( )

Multiplication *

Addition +

Subtraction -

7. 

What is the value of the following expression

42 % 10

Hint - the "%" is the remainder operator

10

1042

2

420

8. 

What will be the value of x after the following statement executes:

x = 1 + 2 * 3 - 8 / 4

5

8

2

4

9. 

What will be the value of x when the following statement is executed:

x = int(98.6)

98

100

99

6

10. 

What does the Python raw_input() function do?

Pause the program and read data from the user

Connect to the network and retrieve a web page.

Read the memory of the running program

Take a screen shot from an area of the screen

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值