WorksheetsPython Basics Test
Total questions: 20
Worksheet time: 10mins
Which is the correct way to create a variable in Python?
x = 5
5 = x
int x = 5
var x = 5
Which variable name is valid?
2name
pizza_size
your-age
What will this code print? x = 10 print(x)
10
x
"x"
Error
What does input("Enter your name: ") do?
Prints the name
Asks the user to type something
Creates a variable
Runs the program
By default, the result of input() is:
int
str
float
bool
Which of these is correct syntax to print a message?
print "Hello"
print(Hello)
print("Hello")
echo("Hello")
Which arithmetic operator is used for multiplication?
x
*
×
mul
What is 15 + 7?
21
22
23
20
What is the result of 20 - 8?
14
10
12
18
What is the result of 5 * 6?
25
35
30
60
What is the result of 12 / 3?
4
6
3
9
Which code correctly converts "25" into an integer?
int("25")
str("25")
25("int")
float(25)
What is the result of float("3")?
"3.0"
3.0
3
Error
Which code changes number 50 into a string?
str(50)
int("50")
float("50")
"50" + 50
What will this code print? name = "Nada" print("Hello " + name)
Hello Nada
name
"Hello Nada"
Hello + name
Which of these is a string in Python?
"apple"
42
3.14
True
Which of these is correct?
print("5 + 3") → prints 8
print(5 + 3) → prints 8
print("5" + 3) → prints "53"
print(5 " + " 3)
Which of these lines will give an error?
x = "10"
y = int(x)
z = x + y
print(z)
Which is the correct way to write a string in Python?
text = 'Hello'
text = "Hello"
Both a and b
None
Which function is always written with parentheses in Python?
input
int
All of the above
