Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

python

Total questions: 40

Worksheet time: 20mins

Name
Class
Date
1.

Which kind of loop would be used?


I need a program that will keep letting me add money to a piggy bank until I get to £100.

a)

FOR Loop

b)

WHILE Loop

2.
What will the output be from the following code?
print("3+4")
a)
7
b)
3+4
c)
34
d)
SyntaxError
3.
To get the users input what function do we use?
a)
Input
b)
input<> 
c)
input() 
d)
INPUT()
4.

Which data type stores whole numbers?

a)

Float

b)

String

c)

Integer

d)

Char

5.

Choose the correct code

a)

print("Hello World")

b)

PRINT(Hello World)

c)

Print("Hello World")

d)

Print"Hello world"

6.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
7.
What would print (10 + 16) produce?
a)
20
b)
22
c)
24
d)
26
8.

Which is the Python logo?

a)
b)
c)
d)
9.

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

10.

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

11.

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!)"

12.

x = 5

y = 6

print("x*y")


The code above displays the following:

a)

11

b)

x*y

c)

Syntax Error

d)

30

13.

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

a)

==

b)

+=

c)

!=

d)

=

14.
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
15.

What is the white space used to enter code called?

a)

Whitespace

b)

IDOL

c)

Shell

d)

IDLE

16.

REPEAT loops can only be used when:

a)

The integers in a calculation aren't decimal

b)

The data to be repeated is in hexadecimal

c)

They don't exist in python

d)

Dealing with named variables

17.

What is a programming language?

a)

Written English

b)

An artificial language used to program a computer

c)

A language used in pseudocode

d)

Machine code

18.

What is a program?

a)

A series of a step-by-step instructions that tell a computer how to solve a task

b)

A video that is watched on a computer

c)

A flowchart written on a computer

d)

The make and model of a computer

19.

You assign a value to a variable with which symbol

a)

@

b)

==

c)

=

d)

*

20.

A string

a)

carries out an action

b)

the elements of a command

c)

a collection of characters

d)

how elements in a commad are arranged

21.

________ is a container for storing data.

a)

Comment

b)

Variable

c)

Casting

d)

None

22.

Is variable name case sensitive?

a)

Yes

b)

No

23.

What is the syntax error with this code:

print”Hello World”

a)

No brackets around "Hello World"

b)

Speech marks are not needed

c)

Colon is not needed

d)

print is spelt incorrectly

e)

Print has a capital P

24.

What is the syntax error with this code:

print(“Hello World”);

a)

No brackets around "Hello World"

b)

Speech marks are not needed

c)

Colon is not needed

d)

print is spelt incorrectly

e)

Print has a capital P

25.

What is the syntax error with this code:

Print(“Hello World”)

a)

No brackets around "Hello World"

b)

Speech marks are not needed

c)

Colon is not needed

d)

print is spelt incorrectly

e)

Print has a capital P

26.

What is the syntax error with this code:

prin(Hello World)

a)

No brackets around "Hello World"

b)

Speech marks are not needed

c)

Colon is not needed

d)

print is spelt incorrectly

e)

Print has a capital P

27.

When you run this program what will this line of code do?

name = input("Enter your name: ")

a)

Ask you to Enter your name and save your answer to Google Drive

b)

Ask you to Enter your name and save your answer to My Documents

c)

Ask you to Enter your name

d)

Ask you to Enter your name and save your answer as a variable

28.

The word 'Tuesday' is which data type?

a)

String

b)

Real/Decimal/Float

c)

Integer

d)

Boolean

e)

Char

29.

The number 45 is what data type?

a)

String

b)

Real/Decimal/Float

c)

Integer

d)

Boolean

e)

Char

30.

number1 = 15

number2 = 10

total = number1 + number2


What is total?

a)

15

b)

10

c)

25

d)

1510

31.

What if the colour entered is red?

colour = input(“Enter the trafficlight colour”)

if colour == “Red”:

print “Stop”

else:

print “Go”

a)

Stop appears on screen

b)

Go appears on screen

c)

Get Ready appears on screen

32.

What if the colour entered is NOT red?

colour = input(“Enter the trafficlight colour”)

if colour == “Red”:

print “Stop”

else:

print “Go”

a)

Stop appears on screen

b)

Go appears on screen

c)

Get Ready appears on screen

33.

All keyword in python are in

a)

lower case

b)

upper case

c)

lower case and uppercase

d)

None of the above

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

What is used for a repetitive task in python?

a)

Loop

b)

List

c)

Data Structure

d)

Boomerang

36.

Do you think indentation in your code is important?

a)

Yes

b)

No

37.

How do we print a statement in python?

a)

print_(x)

b)

print.x

c)

print.(x)

d)

print(x)

38.

What would the output of this calculation be?


print(5*3)

a)

SyntaxError

b)

5*3

c)

(5*3)

d)

15

39.

What will the following code print?


firstName = "John"

surname = "Smith"


print("Hello, my name is " + firstName + surname)

a)

SyntaxError

b)

"Hello, my name is John Smith"

c)

Hello, my name is John Smith

d)

Hello my name is + firstName + surname

40.

What will happen if the following code is run?


name = input("Please enter your name: ")

a)

It will put a name in the code

b)

It will not display anything as there is no print line

c)

It will display an input box so the user can enter their name

d)

It will store a value in the name variable