NEW
Font size
WorksheetsPython study guide
Total questions: 20
Worksheet time: 10mins
What is the result of not setting the value of the year attribute of a date object?
The year defaults to 9999.
The object is invalid.
Cheese
23
Which statement about the datetime.datetime data type is true?
All date variables are required.
All time variables are required.
Mr. Isenhour is the best teacher
43
Which function displays a date object in the form Monday, January 01, 2018?
.strftime("%A, %B %d, %Y")
.strftme("%A, %B %d, %Y")
.srftime("%A, %B %d, %Y")
.stftime("%A, %B %d, %Y")
Python cannot display quotes in strings using print().
True
False
Escape sequences start with a backslash (\).
True
False
Hello
World!
What is the best choice of code to create the output shown above?
print("Hello World!")
print("Hello\tWorld!")
print("Hello\pWorld!")
print("Hello\nWorld!")
\\\\
What is the best choice of code to create the output shown above?
69
Mouse
print("\\\\\\\\")
print(\\\\)
It's
Python Time!
Choose the code that will not create the output shown above.
print("It's" + "\nPython Time!")
print("It's" + "\nPython Time!")
print("It's" + "Python Time!")
print("It's" + "\nPython Time!")
The \t escape sequence moves the text to the right approximately ____ spaces in Python.
3
56
498523948
3234456
What is the best estimate for the output of the code below?
x = 3
y = 3
calculation = x/y
print(calculation)
1.0
9
9.0
3
Looking at the code below, which code example properly calls the function and returns a calculation?
def subtotal(orderAmt, salesTax):
if orderAmt > 0:
subtotal = int(orderAmt) * (1 + float(salesTax))
return subtotal
else:
return "Invalid order amount."
orderTotal = def subtotal(500, 0.07)
orderTotal = subtotal(500, 0.07)
subtotal(500, 0.07)
call subtotal(500, 0.07)
Given x = 9, which line of code will evaluate False?
x = 3
x<3
x==9
3
What is the output from running the code below?
vehicleType = "Truck"
if vehicleType.upper().startswith("P"):
print(vehicleType, 'starts with "P"')
else:
print(vehicleType, 'does not start with "P"')
"Truck does not start with "P""
"Truck starts with "P""
"False"
SyntaxError
What is the output from running the code below?
hotPlate = True
if hotPlate:
print("Be careful, hot plate!")
else:
print("The plate is ready.")
Invalid Code
"The plate is ready."
psdmsomccomscms
"Be careful, hot plate!"
What is the best estimate for the output of the code below?
x = 3
y = 4
calculation = x * y
print(calculation)
9.0
9
12
12.0
In Python string comparisons, lower case "a" is less than upper case "A".
True
False
Which method can be used to return a string in upper case letters?
upper()
toUpperCase()
toUpperCase()
upperCase()
What is the best estimate for the output of the code below?
calculation = 5 + 15 / 5 + 3 * 2 - 1
print(calculation)
13.0
9.0
13
9
What is the output from running the code below?
name = "alton"
print(name == "Alton")
True
Alton
False
Tobias = Alton
Complete the code example to build a function that does the following:
Name is calcSubtotalThe function takes an amount and sales tax rate and calculates a subtotal The new subtotal is returned Name is calcSubtotal The function takes an amount and sales tax rate and calculates a subtotal The new subtotal is returned
(A) ___________________ (B) __________________
subtotal = amount * (1+salesTaxRate)
(C) ___________________
(A) def calcSubtotal (B) (amount, salesTaxRate): (C) return subtotal
(A) def calcSubtotal (B) () (C) return subtotal
(A) function calcSubtotal (B) (amount,salesTaxRate):
(A) calcSubtotal (B) (amount, salesTaxRate) (C) return
