Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python programming Grade 7

Total questions: 46

Worksheet time: 23mins

Name
Class
Date
1.

What is the output of the following program?

for i in range(0, 5):

print(i)

i=i+1

a)

1 to 5 numbers

b)

1 to 4 numbers

c)

0 to 4 numbers

d)

0 to 5 numbers

2.

WHICH ONE OF THE FOLLOWING IS THE CORRECT EXTENSION OF THE PYTHON FILE ?

a)

.py

b)

.python

c)

.p

d)

None of these

3.

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

4.

What does this code do when run the following program: 

name='Aluko' 

print('Hello '+name)

a)

hello aluko

b)

Hello aluko

c)

'Hello Aluko'

d)

Hello Aluko

5.

Python program 3, can carry out calculations. The arithmetic operators we use to do this are: Addition, Subtraction, Multiplication & Division?

a)

Plus, Subtract, Times & Divide

b)

+ - * /

c)

+ - x \

d)

+ - * \

6.

What would this code print

name='Poppy' 

name='Beka' 

print('Hello '+name)

a)

Poppy

b)

Liz

c)

Hello Poppy

d)

Hello Beka

7.

What would this code do?

print('Hello World!')

a)

hello world

b)

Hello World!

c)

hello world!

d)

'Hello World!'

8.

What is the output of these code?

a = 7

b = 8

c = a + b

print(c)

a)

51

b)

15

c)

c

d)

= 7 + 8

9.

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:

10.

What is the output of this code below?

name = input('What is your name? ') Dr Who

print(name + ' ' + name + ' ' + name + ' ' + name + ' ' + name)

a)

Dr WhoDr WhoDr WhoDr WhoDr Who

b)

Dr Who Dr Who Dr Who Dr Who Dr Who

c)

Dr Dr Dr Dr Dr

d)

Who Who Who Who Who

11.

What symbol do you use to make a comment in Python?

a)

@

b)

:

c)

?

d)

#

12.

You assign a value to a variable with which symbol

a)

@

b)

==

c)

=

d)

*

13.

WHICH ONE OF THESE IS USED TO TAKE INPUT FROM THE USERS ?

a)

input

b)

print

c)

system

14.

What is the output of these code?

print(1 + 6)

print(7 - 5)

print(3 * 9)

print(7 / 2)

a)

7

2

27

3.5

b)

7

2

12

3

c)

7

12

6

3.5

d)

7

12

27

3.5

15.

The code you use to receive and input from the keyboard

a)

enter()

b)

add()

c)

receive()

d)

input()

16.

What is missing to complete this code: 

language='Python' 

print('I am learning to program in'______)

a)

+ language

b)

+ Language

c)

language

d)

Language

17.

What would the output of this code be if the user entered the value 70?

a)

Pass

b)

Fail

c)

Merit

d)

Distinction

18.

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

19.

What is the output of the following program?

a)

1 to 10 numbers

b)

1 to 5 numbers

c)

1

d)

5

20.

What would the outcome of this program be?

a)

prints 5 to 50 numbers

b)

prints 5 to 49 numbers

c)

prints 5 to 55 numbers

d)

prints multiples of 5 upto 50

21.

WHICH ONE OF THE FOLLOWING IS NOT SHOWN IN THE SYNTAX ERROR ?

a)

incorrect punctuation

b)

undefined terms

c)

low memory

22.

A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly.

a)

True

b)

False

23.

What does the print function do in python?

a)

It loops the code.

b)

It's a variable.

c)

It can input data.

d)

It displays something like a string or integer

24.

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()

25.

What is a input?

a)

To plug in something

b)

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

c)

Data displayed on a screen

d)

A routine

26.

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

27.

What is the output of the following program?

a)

Yes

b)

No

c)

Error

d)

No output

28.

A program that asks for your first name, your last name and finally greets you with your full name.

name1 = input('What is your first name? ') James

name2 = input('What is your last name? ') Bond

print('Hello ' + name1 + ' ' + name2)

a)

My Name is Bond James Bond

b)

Mr Bond

c)

Hello James Bond

d)

Hello Bond James

29.

What would the outcome of this program be?

a)

prints 1 to 10 numbers

b)

prints 10 to 1 numbers

c)

prints 1 to 15 numbers

d)

prints 1 to 14 numbers

30.

What is the name of the programming language we are learning?

a)

python

b)

scratch

c)

scribble

d)

pie thin

31.

What will be the output?

name = "Dave"

print (name)

a)

Dave

b)

name

c)

"Dave"

d)

(name)

32.

What would this code print?

name='Chan' 

name='Aluko' 

name='WDF'

print(name)

a)

Aluko

b)

Chan

c)

WDF

d)

name

33.

What is the output of the following program?

a)

Yes

b)

No

c)

Error

d)

No output

34.

What does the term 'debug' mean?

a)

Identify errors and fix them

b)

Making a calculation

c)

A set of instructions

d)

Looking at code

35.

Python is an example of a....

a)

language written in java script

b)

Visual-based programming language

c)

Object orientated programming language

d)

Text-based programming language

36.

Returns the remainder from division.

a)

DIV

b)

MOD

37.

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

38.
What is Python really?
a)
Python is an interpreted language.
b)
visual basic
c)
a snake 
d)
a form of font for writing 
39.

Python is ___________ level programming language and is ___________.

a)

High, compiled

b)

High, interpreted

c)

Low, compiled

d)

Low, interpreted

40.

A data type consisting of whole numbers.

a)

integer

b)

float / real

c)

string

d)

boolean

41.

A data type consisting of numbers with decimals.

a)

integer

b)

float / real

c)

string

d)

boolean

42.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
43.
what is 8%2
a)
0
b)
16
c)
24
d)
86
44.
What syntax can you use to insert a line break between strings so that they appear over multiple lines?
a)
/
b)
\n
c)
\l
d)
n
45.
what is python?
a)
a programming language 
b)
a code 
c)
nothing 
d)
a game 
46.

Which of these would work as a piece of code in Python?

a)

IF answer == "Yes":

b)

if answer == "Yes"

c)

if answer == "Yes":

d)

if answer = "yes":