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