1. What is the variable name in the following Python program?
# Name: John Smith
# Date: January 1, 2018
total = 100
print("Start Program Now")
print(total)
NameJohn Smithy
total
2. What data type would an employee salary be best respresented as?
Integer
Float
String
3. What data type would the following Python line store user input as?
x = input("Please enter a temperature (F): ")
IntegerFloat
String
4. Which of the following Python commands would format float output to two digits to the right of
the decimal place?
print("Salary: %2f" % hourly_rate)
print("Salary: 2f" % hourly_rate)
print("Salary: .2f" % hourly_rate)
print("Salary: %.2f" % hourly_rate)
5. What would be the output of this program?
x = 4
y = 2
print(3 * (y + x))
910
14
18
6. Which type of error is one in the logic or algorithm of the program? Programs
with this type of error may still run, but not run correctly or produce the desired output
(choose best answer)
Syntax
Minor
Trace
Semantic
7. What character is used for comments/remarks in Python?
!
*
//
#
8. What do the characters \n do in a Python output statement?
Output a new line, i.e. a carriage return
Output an italized letter n
Output a new paragraph
Output a new page
9. 20percent is a valid variable name in Python
10. What would be the data type of the data stored in the variable age
below?
age = input("Please enter your age?")
IntegerFloat
String
11. What would be the data type of the data stored in the variable age
below?
age = int(input("Please enter your age?"))
IntegerFloat
String
12. In the line of Python code below, what is time considered (choose
best answer)?
import time
a functiona library
a string
a variable
13. In the line of Python code below, what are 2015 and 10 considered (choose
best answer)?
cal = calendar.month(2015, 10)
a functiona parameter
a string
a variable
a list
a procedure
14. Which of the following statements is true?
Both an assignment statement and comparison statement use a == sign
Both an assignment statement and comparison statement use a = sign
A comparison statement uses an = sign, while an assignment statement uses a == sign
An assignment statement uses an = sign, while a comparison statement uses a == sign
15. Debug the following program
Copy and paste the following program into your Python IDE and debug it. There are three syntax errors in it.
# Water temperature program
f_temp = input("Please enter a temperature (F): ")
if f_temp <= 32:
print("At that temperature, water freezes.")
elif f_temp <= 212
print("At that temperature, water is neither freezing or boiling.)
else:
print("At that temperature, water boils.")
16. What will be the output whent his program runs?
x = 5.505
y = 2
z = int(x) * int(y)
print(z)
11.0111.010
10
None of the above
17. Just like filenames in Windows, variables in Python can have spaces in them.