Question: Python Version 3.9.1 1. Which of the following is a comment in Python? a) * This is a test b) // This is a test
Python Version 3.9.1
1. Which of the following is a comment in Python?
a) * This is a test
b) // This is a test
c) /* This is a test */
d) # This is a test
2. What does the following code print out?
print "123" + "abc"
a) This is a syntax error because you cannot add strings
hello world
b) 123+abc
c) 123abc
3. Which of the following is a bad Python variable name?
a) spam23
b) SPAM23
c) spam_23
d) 23spam
4. Which of the following is not a Python reserved word?
a) else
b) spam
c) for
d) if
5. What does the following statement do?
x = x + 2
a) Exit the program
b) This would fail as it is a syntax error
c) Increase the speed of the program by a factor of 2
d) 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?
a) Parenthesis ( )
b) Subtraction -
c) Multiplication *
d) Addition +
7. What is the value of the following expression
42 % 10
(Hint - the "%" is the remainder operator)
a) 0.42
b) 420
c) 1042
d) 2
8. What is the value in x after the following statement executes:
x = 1 + 2 * 3 - 8 / 4
a) 4
b) 5
c) 15
d) 8
9. What value be in the variable x when the following statement is executed
x = int(98.6)
a) 100
b) 99
c) 98
d) 6
10. What does the Python raw_input() function do?
a) Connect to the network and retrieve a web page.
b) Take a screen shot from an area of the screen
c) Read the memory of the running program
d) Pause the program and read data from the user
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
