wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python

Total questions: 15

Worksheet time: 15mins

Name
Class
Date
1.
Which command will display the text 'Hello world!' on the screen?
a)
print(Hello world!)
b)
print "Hello world!"
c)
print("Hello world!")
d)
print = "Hello world!"
2.
Which command will correctly ask the user for their age?
a)
age = input("How old are you?")
b)
age = input(How old are you?)
c)
input("How old are you?") = age
d)
How old are you = input()
3.
Which function will convert a number to a string?
a)
int()
b)
str()
c)
ord()
d)
chr()
4.
What is the result of this command? print ("5" + "3")
a)
8
b)
"5" + "3"
c)
"8"
d)
53
5.
Which function will convert a string containing only digits into a number?
a)
int()
b)
str()
c)
ord()
d)
chr()
6.
Which decision statement will be triggered if the variable x is less than 20?
a)
if x > 20:
b)
if x <> 20:
c)
if x == 20:
d)
if x < 20:
7.
15. Which of these tests whether the variable x is the same as 'Hello'?
a)
x = "Hello"
b)
x != "Hello"
c)
x == "Hello"
d)
x <> "Hello"
8.
What effect does the # character have?
a)
Tells Python that this is a really important line of code.
b)
Tells Python to ignore the rest of the line.
c)
Tells Python to tweet when this line of code gets run.
d)
It does nothing, Python ignores this character.
9.
What is a variable?
a)
A piece of data that can change
b)
A piece of data you cannot change
c)
A coding technique
d)
A special file
10.
What does input do?
a)
It allows users to change the program
b)
It converts data types
c)
It allows a user to solve a task
d)
It allows users to enter data
11.
what data type is 3.95?
a)
Intager
b)
Float
c)
String
d)
Character
12.
What would the output of this code be if the user entered the value 70?
a)
Pass
b)
Fail
c)
Merit
d)
Distinction
13.
What would the outcome of this program be?
a)
22
b)
50
c)
Nothing, it won't run due to errors in the code
d)
38
14.
myName = input() - Is myName a string, a function, a variable, or a method
a)
String
b)
Function
c)
Variable
d)
Method
15.
How would we fix this code?
a)
Removed the ' ' from around Bob
b)
Remove the '='
c)
Remove the ( ) around name
d)
Make 'Name' lower case