WorksheetsPython - Basic Variables, Arithmetic and Display
Total questions: 20
Worksheet time: 10mins
In Python, which of these assigns an integer to x?
int x = 5
x = 5
x := 5
x == 5
Which data type would the value "Hello" be?
int
string
boolean
float
In Python, what is the result of 3+7?
10
37
"3 + 7"
4
In Python, what is the result of "3"+"7"?
10
37
"3 + 7"
4
In Python, which of these displays what is stored in a variable called `name`?
print name
print(name)
echo(name)
printf(name)
In Python, which of these is a boolean value?
"True"
1
True
"False"
false
What is the result of 8-3 in Python?
5
83
-5
3
38
Which of the following is NOT a basic data type in Python?
int
string
boolean
list
What will print(2 * 4) output?
8
24
6
2 * 4
Nothing
Which of these is a valid assignment in Python?
language = "Python"
language == "Python"
language := "Python"
string language = "Python"
What is the result of 10/2 in Python?
5
October 2nd
2
0.2
10
x = 7
y = 3
What is displayed by print(x + y)?
10
21
4
73
37
name = "Alice"
Which of these will print "Hello, Alice"?
print("Hello, name")
print("Hello, ", name)
print(Hello, name)
print(name, "Hello,")
a = 5
b = 2
What is the result of a * b?
10
7
3
25
52
What is displayed by this Python code?
is_student = True
print(is_student)
"True"
True
1
Yes
is_student
x = 10
Which statement prints "The value is 10"?
print("The value is", x)
print("The value is" + x)
print("The value is x")
print(x, "The value is")
print(x)
If x = 4, what is the result of x * x?
8
16
4
2
flag = False
Which statement will display the value of flag?
print(flag)
print("flag")
print(False)
print(flag == False)
What data type is stored in the variable x?
x = False
int
string
boolean
What data type is stored in the variable x?
x = "Today"
int
string
boolean
