wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Test 1

Total questions: 87

Worksheet time: 59mins

Name
Class
Date
1.
The number or word we give to a variable
a)
Value
b)
Bug
c)
Information
d)
Text
2.
What is the word (command) used to display numbers and text on the screen?
a)
print
b)
input
c)
output
d)
command
3.
What is a variable?
a)
A box(memory location) where you store values
b)
a type of graphics
c)
Data type
d)
a type of memory
4.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
5.
What is the name of the programming language we are learning?
a)
Scratch
b)
Python
c)
Pie thin
d)
Scribble
6.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
7.
Python is an example of a....
a)
Text-based programming language
b)
Object orientated programming language
c)
language written in java script
d)
Visual-based programming language
8.
What would print (10 + 16) produce?
a)
20
b)
22
c)
24
d)
26
9.
What button do you press to compile (run) your program so that it runs in the shell?
a)
F3
b)
F5
c)
F7
d)
F9
10.

Which is the Python logo?

a)
b)
c)
d)
11.

What is a input?

a)

A function that allows us to ask the user to enter some data.

b)

To plug in something.

c)

Data displayed on a screen.

d)

A function

12.

What function is used to output a message in python?

a)

print("")

b)

input=name

c)

print

d)

name=input

13.

x = 5

y = 6

print(x*y)


The code above displays the following:

a)

11

b)

x*y

c)

Syntax Error

d)

30

14.

Operators used in python:


divide, multiply, add, subtract

a)

/, *, +, -

b)

div, mul, +, -

c)

\, x, +, -

d)

~, *, +, -

15.
How would would you print a text string?
a)
output "Hello!"
b)
print ("Hello!")
c)
print (Hello!)
d)
output (Hello!)
16.

Which of the following is a command to have a message appear on the screen?

a)

print

b)

write

c)

msg

d)

input

17.

Pick the Python command used to let the user type in some data

a)

get

b)

input

c)

int

d)

float

18.

Which of the following is a Python command word used to indicate we want to work with WHOLE numbers

a)

input

b)

int

c)

float

d)

print

19.

Which of the following is a Python command word used to indicate we want to work with DECIMAL numbers

a)

input

b)

int

c)

float

d)

print

20.

Which of the following is a Python command word used to indicate we want to set up a fixed loop

a)

while

b)

print

c)

next

d)

for

21.

What would be printed by the command

print('12-5')

a)

12-5

b)

'12-5'

c)

7

d)

'7'

22.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
23.

Which of the following is used in Python to give a value to a variable

a)

:=

b)

==

c)

=

24.
The character that must be at the end of the line for if, while, for etc.
a)
:
b)
;
c)
.
d)
,
25.

What would be printed by the command

print('12-5')

a)

12-5

b)

'12-5'

c)

7

d)

'7'

26.

Which of the operators do we use if we want at least one condition to be true?

a)

and

b)

or

c)

else

d)

not

27.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
28.

What will be the output of the following statement?

type('5')

a)

str

b)

int

c)

float

d)

Boolean

29.

What is the correct file extension for Python files?

a)

.py

b)

.pt

c)

.pyt

d)

.pyth

30.

How do you create a variable with the numeric value 5?

a)

Both are correct

b)

x=5

c)

x=int(5)

31.

Which operator can be used to compare two values?

a)

=

b)

<>

c)

><

d)

==

32.

Which of the following is a data type in Python? Select multiple answers.

a)

int

b)

words

c)

string

d)

decimals

33.

a = "Good Morning!"

print(len(a))

a)

13

b)

12

c)

11

d)

14

34.

a = "Hello, World!"

print(a.lower())

a)

hello, World!

b)

HELLO, WORLD!

c)

hello, world!

d)

Error

35.

x = 23

y = 3


print(x // y)

a)

7

b)

7.6666

c)

7.7

d)

Error

36.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
37.
What will the output be from the following code?
print(3+4)
a)
3+4
b)
7
c)
SyntaxError
d)
print(3+4)
38.
What will the output be from the following code?
print("3+4")
a)
7
b)
3+4
c)
34
d)
SyntaxError
39.

What will the output be from the following code?

print("Hello world!\nHello world!") (aka new line)

a)

Hello world! Hello world!

b)

Hello world!

Hello world!

c)

SyntaxError

d)

Hello world!

40.
Joining elements together to make a string is called what?
a)
Combining
b)
Connecting
c)
Concatenation
d)
Stringing
41.
What will the output be from the following code?
print("Hello" + "world!")
a)
Hello world!
b)
Helloworld!
c)
SyntaxError
d)
"Hello" "world!"
42.
What will the output be from the following code?
print("Hello" + "world" + "today")
a)
Helloworldtoday
b)
Hello world today
c)
"Hello" "world" "today"
d)
SyntaxError
43.
To create a newline at the end of prompt, you can use which of the following expressions?
a)
\new
b)
\n
c)
\break
d)
\return
44.
The number or word we give to a variable
a)
Value
b)
Bug
c)
Information
d)
Text
45.
Why is it called 'Python'?
a)
The guy who created it loves snakes
b)
The guy who created it loves Monty Python films
c)
You can create a game on python called snake
d)
It was created by someone called Mr Python
46.
What would print (10 + 16) produce?
a)
20
b)
22
c)
24
d)
26
47.

Everything that we want do display in a print() function must:

a)

be inside parentheses - ()

b)

quotation marks - ""

c)

be inside single quotation marks - ''

d)

be inside hash marks - #

48.
Select all the correct answers for float data type:
a)
True
b)
25.4
c)
34
d)
[Hello]
49.

In Python, variables are black, functions are purple and strings are green? True or False

a)

True

b)

False

50.

What is a correct syntax to output "Hello World" in Python?

a)

echo("Hello World")

b)

echo "Hello World"

c)

print("Hello World")

d)

PRINT("Hello World")

51.

What is the correct file extension for Python files?

a)

.py

b)

.pt

c)

.pyt

d)

.pyth

52.

Which operator can be used to compare two values?

a)

=

b)

<>

c)

><

d)

==

53.

How do you create a variable with the numeric value 5?

a)

Both are correct

b)

x=5

c)

x=int(5)

54.

How do you create a variable with the floating number 2.8?

a)

x=2.8

b)

x=float(2.8)

c)

both are correct

55.

If num1 = 5

num2 = 6

then what will be the output of num1*num2

a)

11

b)

6

c)

30

d)

-1

56.

If num1 = 3

num2 = 4

then what will be the output of num1 ** num2

a)

3

b)

7

c)

12

d)

81

57.

Which operator checks if a value is equal to another value?

a)

+

b)

-

c)

==

d)

!=

58.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
59.

Which is the Python logo?

a)
b)
c)
d)
60.

What is an input?

a)

A command that allows us to ask the user to enter some data.

b)

To plug in something.

c)

Data displayed on a screen.

d)

A function

61.

What is an output?

a)

A piece of data that is shown on the screen.

b)

Data that the user enters

c)

An output

d)

A orange

62.

To display the following on screen

Hello World!

the following command should be used:

a)

print(Hello World!)

b)

print("Hello World!")

c)

print("Hello World" + !)

d)

print"(Hello World!)"

63.

x = 5

y = 6

print("x*y")


The code above displays the following:

a)

11

b)

x*y

c)

Syntax Error

d)

30

64.

Choose the correct operators used in python:


divide, multiply, add, subtract

a)

/, *, +, -

b)

div, mul, +, -

c)

\, x, +, -

d)

~, *, +, -

65.

Which operator checks if a value is not equal to another value?

a)

==

b)

+=

c)

!=

d)

=

66.

A data type that can have one of two values: True or False

a)

boolean

b)

variable

c)

modulo

d)

interpreter

67.
What will the following code do? 
name = "Bob"
if name == "Bob": 
     print ("Hello " + name) 
else:  
     print ("I dont know you")
a)
prints bob
b)
prints Hello Bob
c)
nothing syntax error
d)
prints I don't know you
68.
Which of the following is not a string?
a)
new_var = "True"
b)
new_var = "3123"
c)
new_var = "3.123"
d)
new_var = False
69.
What will the following code do? 
name = "Bob"
if name == "Bob": 
     print ("Hello " + name) 
else:  
     print ("I dont know you")
a)
prints bob
b)
prints Hello Bob
c)
nothing syntax error
d)
prints I don't know you
70.

Integers are ____________ and floats are _____________

a)

whole numbers and exponents

b)

powers and fractions

c)

fractions and whole numbers

d)

whole numbers and decimal numbers

71.
What will the output be from the following code?
print(3+4)
a)
3+4
b)
7
c)
SyntaxError
d)
print(3+4)
72.
What extension must you add to the end of a file when saving?
a)
.xlsx
b)
.pptx
c)
.docx
d)
.py
73.
What does the print function do in python?
a)
It's a variable.
b)
It can input data.
c)
It displays something like a string or integer
d)
It loops the code.
74.
What is the correct definition for a VARIABLE?
a)
a changeable value, such as a score in a computer game.
b)
a value that cannot be changed
75.
Data type that can only be true or false
a)
int
b)
string
c)
bool
d)
float
76.
What will the output be from the following code?
print(3*4+5)
a)
27
b)
17
c)
12
d)
SyntaxError
77.

Which of these is a string?

a)

42

b)

True

c)

"This one!"

d)

No, this one

78.

How to create a numeric variable age with a value of 10

a)

age = 10

b)

age = int(10)

c)

age = "10"

79.

In python, "Hello World" is the same as 'Hello World'

a)

True

b)

False

80.

How is a block of code defined in Python ?

a)

with indentation

b)

with paranthesis

c)

with curly braces

81.

age = '5'


In the code above, age is a

a)

string

b)

integer

c)

floating point

82.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
83.
A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly
a)
True
b)
False
84.
What is the name of the programming language we are learning?
a)
Scratch
b)
Python
c)
Pie thin
d)
Scribble
85.
Which of these would work as a piece of code?
a)
IF answer == "Yes":
b)
if answer == "Yes"
c)
if answer == "Yes":
d)
if answer = "yes":
86.
If you want more than one option for your code, what do you use (after if)?
a)
elif
b)
else
c)
ifif
87.
What is the answer to print (12/6)?
a)
1
b)
2
c)
6
d)
10