WorksheetsPython Basics Quiz
Total questions: 12
Worksheet time: 9mins
What is the purpose of a variable in Python?
To store data
To print text
To perform calculations
To comment on code
How do you concatenate (add together) two strings in Python?
str1 + str2
str1 . str2
str1, str2
concatenate(str1, str2)
What does the print() function do in Python?
Takes user input
Displays output to the console
Performs mathematical operations
Declares variables
Which of the following is used to take user input in Python?
get_input()
read_input()
input()
user_input()
Which of the following is a valid string in Python?
"dog"
dog
(dog)
^dog^
What is the output of the following code?
x = "apple"
y = "banana"
z = x + y
print(z)
x + y
apple banana
z
What data type does the input() function return?
Integer
Float
String
Boolean
What is the output of the following code?
big = "Apple"
little = "Grape"
mix = little + big
print(mix)
GrapeApple
AppleGrape
mix
Which of the following is the correct way to store the string "dog" in a variable called var?
var = "dog"
"dog" = var
var := "dog"
var -> "dog"
What is the output of the following code?
fruit1 = "Mango"
fruit2 = "Pineapple"
result = fruit1 + fruit2
print(result)
MangoPineapple
PineappleMango
fruit1fruit2
result
What is the output of the following code?
num1 = "5"
num2 = "7"
result = num1 + num2
print(result)
57
12
num1num2
result
Which of the following is the correct way to store the string "cat" in a variable called animal?
animal = "cat"
"cat" = animal
animal := "cat"
animal -> "cat"
