Font size
WorksheetsPython: Print Function, Data Types, and Variables
Total questions: 20
Worksheet time: 27mins
What is the correct way to declare a string variable in Python?
string name = "Hello"
str name = "Hello"
name = "Hello"
name = Hello
Which of the following is an integer in Python?
3.14
"42"
42
True
How do you correctly print the text "Hello, World!" in Python?
(a)
Which of the following is a floating point number?
7
7.0
"7.0"
True
What is the boolean value of the expression 5 > 3 in Python?
(a)
Which of the following is a correctly named variable in Python?
1st_variable
firstVariable
first-variable
first variable
What will be the output of the following code: print(3 + 4.5)?
(a)
What is the result of the expression 10 // 3 in Python?
(a)
Which of the following is NOT a valid way to name a variable in Python?
my_variable
myVariable
my-variable
_myVariable
What will be the output of the following code: print("5" + "3")?
(a)
What is the result of the expression 4 * 2.5 in Python?
(a)
Which of the following statements will print the boolean value False?
print(5 > 10)
print(10 > 5)
print(5 == 5)
print("False")
What is the correct way to declare a variable with a floating point number in Python?
float number = 3.14
number = 3.14
number = "3.14"
float number = "3.14"
How do you create a variable named bestNumber with the numeric value 5 in Python?
(a)
How are variables declared in Python?
Two students are given the following line of code:
print(7 + 8 + "I love pizza")
Student 1 says that the computer will print 7 8 I love pizza to the console.
Student 2 says that the computer will print an Error message.
Which student is correct and why?
Tom is coding a application using the Python coding language. He wants the computer to print "My name is Tom and I am 24 years old!" to the console using the following code:
user_name = Tom
age = 24
print("My name is, Tom, "and I am", 24, "years old!")
What is wrong with Tom's code and how can he fix it making sure he uses variables?
Type the code that would tell people your favorite movie. Make sure that if the code was ran that your name and the name of your favorite movie would be included. Also make sure that your code includes 2 different variables.
Type the Python code that would print your first and last name to the console.
Type the Python code that has an equation that would print the integer 1 to the console and that uses 3 different operators.
