wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python First Steps Homework Quiz

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

A set of precise instructions that is meant to solve a problem is .......................

a)

a computer

b)

an algorithm

c)

a program

d)

an interpreter

2.

What symbol is used in python to assign values to a variable?

a)

plus +

b)

forward slash /

c)

equals =

d)

asterisk *

3.

Read the Python program:


When this program is executed, what will be displayed on the screen?


Note: There may be errors in the program and/or it may not behave as expected.

a)

"I live in", location

b)

"I live in", "Leeds"

c)

I live in location

d)

I live in Leeds

4.

Read the Python program:


When this program is executed, what will be displayed on the screen, as a result of executing line 3?


Note: There may be errors in the program and/or it may not behave as expected.

a)

I’ve never been to and whatever the user has typed at the keyboard

b)

I’ve never been to location

c)

I’ve never been to input()

d)

It is not possible to know the output without executing the program.

5.

Which feature of programming involves a decision, but does not involve repeats?

a)

Sequence

b)

Selection

c)

Iteration

6.

Read the Python program below:


1. answer = 3 + 13 * 3

2. print("The Answer is", answer)


When this program is executed, what will be displayed on the screen?


Note: There may be errors in the program and/or it may not behave as expected.

a)

The Answer is 3 + 13 * 3

b)

The Answer is 42

c)

The Answer is 48

d)

The Answer is answer

7.

The code you use to receive an input from the keyboard

a)

enter()

b)

receive()

c)

add()

d)

input()

8.

Read the Python program:


When this program is executed, what will be displayed on the screen if the user enters 0 at the prompt?

a)

0 is positive 0 is negative

b)

0 is positive

c)

0 is negative

d)

The program will not display anything because 0 is neither positive nor negative.

9.

What is the word (command) used to display numbers and text on the screen?

a)

print

b)

output

c)

input

d)

command

10.

A WHILE loop is an example of which type of feature

a)

Sequence

b)

Selection

c)

Iteration

d)

Concatenation

11.

Read the Python program:


When this program is executed, what will be displayed on the screen?


Note: There may be errors in the program and/or it may not behave as expected.

a)

small

b)

medium

c)

medium large

d)

large

12.

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

13.

If you receive a NameError (name is not defined) when you run your program it means....

a)

A variable has been assigned before it has been referred to.

b)

An incorrect name has been chosen.

c)

A variable has been referred to before it has been assigned.

d)

A language key word has been used.

14.

What will be the output?

1. name = "Dave"

2. print (name)

a)

"Dave"

b)

name

c)

(name)

d)

Dave

15.

Read the Python program:


When this program is executed, how many times will line 4 be executed?


Note: There may be errors in the program and/or it may not behave as expected.

a)

Line 4 will be executed once.

b)

Line 4 will be executed at least once.

c)

Line 4 will be executed 1357 times.

d)

Line 4 will be executed an infinite number of times (the while loop will never terminate).

16.

Which line of code would create a variable called

my_message

and give it the value

"bye"?:

a)

my_message = “bye”

b)

“my_message” = bye

c)

variable my_message = “bye”

d)

my_message(“bye”)

17.

What will the output be from the following code?

Print("Hello world!")

a)

Hello world!

b)

"Hello world"

c)

NameError

d)

Print(Hello world!)

18.

Read the Python program:


How many times will line 3 be executed?


Note: There may be errors in the program and/or it may not behave as expected.

a)

None (the condition in line 2 will be False the first time it is checked)

b)

1

c)

3

d)

4

e)

Infinitely (the condition in line 2 will never become False)

19.

Read the Python code:


Which code is missing from line 11 to ''raise the Boolean flag' and end the game?

a)

guessed = True

b)

guessed = False

c)

guessed == True

d)

guessed = "False"

20.

What syntax would you use to create a name variable?

a)

name=input{}

b)

input=name

c)

name=input()

d)

name=INPUT