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 + 2This 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 % 10Hint - 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 / 45
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
總結
以上是生活随笔為你收集整理的Coursera课程Python for everyone:chapter 2的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Coursera课程:Python fo
- 下一篇: Coursera课程Python for