Py4e: Chapter 2
Which of the following is not a Python reserved word?
speed, spam
What will be the value of x after the following statement executes: x = 1 + 2 * 3 - 8 / 4
5.0
Which of the following is a bad Python variable name?
#spam
What is the value of the following expression: 42 % 10 Hint - the "%" is the remainder operator
2 the remainder since 4*10=40
What will be the value of x when the following statement is executed: x = int(98.6)
98
In the following code, print(98.6) What is 98.6?
A constant
Which of the following elements of a mathematical expression in Python is evaluated first?
Parentheses ( )
What does the Python input() function do?
Pause the program and read data from the user
In the following code, x=42 What is x?
a variable
Assume the variable x has been initialized to an integer value (e.g., x = 3). What does the following statement do? x = x + 2
Retrieve the current value for x, add two to it and put the sum back into x