Py4e: Chapter 2 Questions and Answers|
Latest Update
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
Which of the following elements of a mathematical expression in Python is evaluated first?
Parentheses ( )
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 after the following statement executes: x = 1 + 2 * 3 - 5.0
What will be the value of x when the following statement is executed: x = int(98.6) 98
What does the Python input() function do? Pause the program and read data from the user
Which of the following is a bad Python variable name? #spam
In the following code, print(98.6)
Latest Update
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
Which of the following elements of a mathematical expression in Python is evaluated first?
Parentheses ( )
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 after the following statement executes: x = 1 + 2 * 3 - 5.0
What will be the value of x when the following statement is executed: x = int(98.6) 98
What does the Python input() function do? Pause the program and read data from the user
Which of the following is a bad Python variable name? #spam
In the following code, print(98.6)