wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python

Total questions: 40

Worksheet time: 40mins

Name
Class
Date
1.

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

a)

print

b)

write

c)

msg

d)

input

2.

Pick the Python command used to make the user type in some data (input the data)

a)

get

b)

input

c)

int

d)

float

3.

Which of the following Python command can be used for WHOLE numbers?

a)

input

b)

int

c)

float

d)

print

4.

What would be printed by the command

print("12-5")

a)

12-5

b)

'12-5'

c)

7

d)

'7'

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

Below is the code for printing student's name. What is the best answer to put in (?)


name = student

print ( ? )

a)

text

b)

print

c)

name

d)

student

7.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
8.
What is the name of the programming language we are learning?
a)
Scratch
b)
Python
c)
Pie thin
d)
Scribble
9.

What will be the output?

name = "Dave"

print (name)

a)

Dave

b)

'Dave'

c)

name

d)

(name)

10.
What is Python?
a)
text based programming language
b)
word processor 
c)
spreadsheet
d)
block based programming language
11.

Python has a simple syntax similar to the

a)

coding language

b)

english language

c)

spanish language

12.

Code for Hello, World!

a)

print Hello, World!

b)

print("Hello, World!)

c)

print("Hello, World!")

13.

Insert the missing part of the code below to output

_________________ "My name is ".

a)

Print

b)

PRINT

c)

print

14.

Python language use

a)

upper case letters

b)

lower case letters

c)

upper and lower case letters

15.

The output of the program

x = 4

x = "Sally"

print(x)

a)

four

b)

Saly

c)

Sally

16.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
17.
What is the name of the environment in Python that write your programs and then test them out?
a)
Shell
b)
Window
c)
IDLE
d)
CLI
18.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
19.
What does the print function do in python?
a)
It's a variable.
b)
It can input data.
c)

It displays an output

d)
It loops the code.
20.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
21.
what is correct code for INTEGER in python?
a)
in
b)
ing
c)
int
22.
What will the output be from the following code?
print("3+4")
a)
7
b)
3+4
c)
34
d)
SyntaxError
23.

Which is the Python logo?

a)
b)
c)
d)
24.

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

25.

What is a output?

a)

A piece of data that is shown on the screen.

b)

Data that the user enters

c)

An output

d)

A orange

26.

What is the name of the variable in this program?

a)

print

b)

colour

c)

input

d)

" "

27.

What will this code print?

a)

access denied

b)

access granted

c)

error

d)

password

28.

What symbol must you place at the end of an if statement?

a)

)

b)

:

c)

;

d)

}

29.
What best defines an IF statement in python?
a)
Is an embedded string with a variable
b)
An IF statement checks to see if a statement is true or false and then does one of two things depending on the result.
30.

x = 5

y = 6

print(x*y)


The code above displays the following:

a)

11

b)

x*y

c)

Syntax Error

d)

30

31.

How many variables are there in this program?

a)

2

b)

3

c)

4

d)

5

32.
The second part of if, that is executed when the condition is false
a)
if
b)
else
c)
for
d)
input
33.
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
34.

Spelling is not important in Python (it will know what you meant to type)

a)

True

b)

False

35.

Which operator performs an addition?

a)

-

b)

+

c)

==

d)

/

36.
What extension must you add to the end of a file when saving?
a)
.xlsx
b)
.pptx
c)
.docx
d)
.py
37.

What result will display in the shell if 15 and 20 is entered by the user?

a)

"num1 + num2"

b)

1520

c)

35

38.

x = 5

if x > 6 :

print("Hello")

else:

print("Hi")

a)

Hi

b)

Hello

39.

x = 5

y = 6

if x > y or y == 6:

print("Hi")

else:

print("Hello")

a)

Hi

b)

Hello

40.

find the output

print("welcome")

a)

Welcome

b)

welcome

c)

WELCOME

d)

WelCome