NEW
Font size
WorksheetsTechSmart Unit 1 Review
Total questions: 32
Worksheet time: 2hrs 36mins
After this code executes, what is the value of the variable name?
name = input("What is your name? ")
name = "Frank Duvall"
What is your name?
Frank Duvall
Name
Whatever the user inputs
A statement is...
A line of code that performs some action
A line of code that ends with a period
A line of code that begins with a # mark
A way to make your code more fashionable
What does the print( ) command do?
It causes text output to appear in the console
It gets text input from the user
It turns on the printer
It adds the symbols ( ) to the end of a line
int( ) is an example of what type of command?
Concatenation ("catting")
Output
Typecast
Interior
What is a variable?
A type of string literal
A container that holds information
The place where output appears
The difference between two values
In the following line of code, ID the string literal. (There is only one.)
superhero = "Captain America"
print(superhero)
superhero
Captain America
"Captain America"
Which of the following data types can be assigned to variables?
String
Integer
Float
All of these
None of these
What is the data type of the value 11.46?
String
Integer
Float
Increment
Given the following code, if the user enters 25 as input, what is the final output?
var = input("Please enter a value: ")
total = int(var) + 15
print(total)
25
15
10
40
What command creates text output in Python?
input("What is your name? ")
name = input("What is your name? ")
print(name)
int(name)
What type conversion (typecasting) should be used for the input below?
pets = input("Enter the number of pets you have: ")
str(pets)
float(pets)
int(pets)
num(pets)
What type conversion (typecast) should be used for the variable total in line 2 below?
pets = 2 + 2
print("The total is: " + pets)
str(pets)
float(pets)
int(pets)
num(pets)
Given the following code, choose the output that would appear in the console.
food1 = "Chicken "
food2 = "Soup"
print(var1 + var2)
Chicken Soup
Chicken
Soup
"Chicken Soup"
Given the following code, choose the output that would appear in the console.
num = "Eleven"
num = "Twelve"
print(num)
"Eleven"
Twelve
Eleven
"Twelve"
Given the following code, choose the output that would appear in the console.
var = "Yo, "
var += "Adrian!"
print(var)
Yo,
Adrian!
"Yo, Adrian!"
Yo, Adrian!
Identify the literals in the following code. (There are 2.)
design = "^%^" + var + " #@#"
"^%^"
" #@#"
Both
Neither
Change line 2 of this code so that the dog's name is printed after the word Here (on the same line).
dog = input("Enter your dog's name: ")
print("Here, ")
print("Here, " dog)
print("Here, " + dog)
print("Here, dog")
print("Here, " + "dog")
Correct the syntax error in the code below so it prints Buy a yearbook.
print "Buy a yearbook."
print("Buy a yearbook.")
print + "Buy a yearbook."
print ("Buy a yearbook.")
print(Buy a yearbook.)
Correct the syntax error in the code below so it prints Buy a yearbook.
print(Buy a yearbook.)
print("Buy a yearbook.")
print + "Buy a yearbook."
print ("Buy a yearbook.")
print(Buy a yearbook.)
Add a str() typecast to the code below to prevent an error.
num = 42
print("The number is: " + num)
prin(str("The number is: " + num))
print("The number is: " + str("num"))
print("The number is: " + str(num)
print("The number is: " + str(num))
Add an operator to the code below to prevent an error.
var input("Enter a value: ")
print(var)
var=input("Enter a value: ")
var = input("Enter a value: ")
var + input("Enter a value: ")
var-input("Enter a value: ")
Which of the following is NOT a useful quality of error messages?
They let us know the computer didn't understand something
They force a program to run until the end, instead of quitting early
They give a hint about where the error is
They give a hint about what the error is
Why are variables useful?
Unknown values can be stored in them
The same value can be used in multiple places
Complicated calculations can be broken into pieces
All of these
Rewrite this line of code to use the increment operator.
num = num + 10
num = num += 10
num = num =+ 10
num = num -= 10
num = num =- 10
What symbol is used for the assignment operator?
+
-
=
*
In the code below, which uses the concatenation (catting) operator and NOT the addition operator.
money = input("How much is your phone worth? ")
value = 100 + int(money)
print("Your phone is now worth $" + str(value))
value = 100 + int(money)
print("Your phone is now worth $" + str(value))
What is the final value stored in num?
num = "18" + "18"
36
"36"
1818
There's not enough information to be sure
Which of the following is an expression, but not a statement?
(Hint: Expressions produce values, statements DO something.)
50 + 50
x = 50
x += 50
print("50")
What value is the result of this expression?
55 % 5
11
5
275
60
Which line would be ignored by the computer?
"""
Code Stuff
"""
# Code Stuff
Both
Neither
"""
Code Stuff
"""
# Code Stuff
What data type is the result of the following expression?
11 / 3
String
Integer
Float
Input
What data type is the result of the following expression?
input("What is your favorite animal? ")
String
Integer
Float
Input
