Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Introduction to Python Programming

Total questions: 40

Worksheet time: 3hrs 16mins

Name
Class
Date
1.

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

a)

"I live in", location

b)

"I live in", "Leeds"

c)

I live in location

d)

I live in Leeds

2.

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

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.

3.

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

a)

The Answer is 3 + 13 * 3

b)

The Answer is 42

c)

The Answer is 48

d)

The Answer is answer

4.

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

a)

13 42

b)

42 13

c)

a b

d)

There is an error in the program because variables a and b are not assigned values in the right order.

5.

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

a)

13 42

b)

42 13

c)

There is an error in the program because variables a and b are not assigned values in the right order.

d)

There is an error in the program because when line 1 is executed, variables a and b have not been assigned values.

6.

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

a)

13

b)

42

c)

13 42

d)

There is an error in the program because variable a cannot hold two values at the same time.

7.

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

a)

13 42

b)

13 13

c)

42 13

d)

42 42

8.

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

a)

13 14

b)

13 a+1

c)

a b

d)

There is an error in the program because when line 3 is executed, variable a no longer has a value.

9.

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)

13

b)

14

c)

13 14

d)

There is an error in the program because there are no values for variable a that could be used in the equation in line 3.

10.

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

a)

14

b)

43

c)

14 43

d)

There is an error in the program because variable b cannot hold two values at the same time.

11.

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

a)

13

b)

26

c)

13 26

d)

Line 3 will not be executed because there is an error in line 2: print cannot display expressions such as 2*a.

12.

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

a)

You should try a little Python too

b)

Hello Pythonista

c)

You should try a little Python too Hello Pythonista

d)

There is an error in the program, because there should not be any quotes around "Python" in line 3.

13.

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

a)

You should try a little Python too

b)

Hello Pythonista

c)

You should try a little Python too Hello Pythonista

d)

Hello Pythonista You should try a little Python too

e)

There is an error in the program, because there should not be any quotes around "Python" in line 3.

14.

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

a)

You should try a little Python too

b)

Hello Pythonista

c)

You should try a little Python too Hello Pythonista

d)

There is an error in the program, because there should be quotes around Python in line 3.

15.

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

a)

You should try a little Python too

b)

Hello Pythonista

c)

Nothing will be displayed on the screen

d)

There is an error in the program, because there is no else.

e)

You should try a little Python too Hello Pythonista

16.

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 negative

c)

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

d)

0 is positive

17.

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

a)

0 is zero

0 is non-zero

b)

0 is non-zero

c)

There is a syntax error in the condition in line 3.

d)

0 is zero

18.

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

a)

30 minutes is 0.5 hours

b)

30 minutes is less than an hour

c)

30 minutes is less than an hour

30 minutes is 0.5 hours

d)

There is a syntax error in the condition in line 3

19.

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

a)

90 minutes is 1.5 hours

b)

90 mi

c)

90 minutes is less than an hour

90 minutes is 1.5 hours

d)

There is a syntax error in the condition in line 3.

20.

When this program is executed, what will be displayed on the screen, if the user enters 90 at the prompt? Note: There may be errors in the program and/or it may not behave as expected.

a)

90 minutes is 1.5 hours

b)

90 minutes is less than an hour

c)

90 minutes is less than an hour

90 minutes is 1.5 hours

d)

There is a syntax error in the condition in line 3.

21.

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

a)

Nothing will be displayed on the screen.

b)

zero

c)

13

0

d)

13

0

zero

22.

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

a)

Nothing will be displayed on the screen.

b)

13

c)

13

zero

d)

13

aero

0

23.

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

a)

There is an error in the program because when line 1 is executed, variable number has not been assigned a value.

b)

Nothing will be displayed on the screen.

c)

13

zero

d)

13

zero

0

24.

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

a)

small

b)

medium

c)

medium

large

d)

large

25.

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

a)

small

b)

medium

c)

medium

large

d)

large

26.

How many times will line 3 be executed?

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)

27.

How many times will line 3 be executed?

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)

28.

How many times will line 3 be executed?

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)

29.

How many times will line 3 be executed?

a)

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

b)

1

c)

2

d)

3

e)

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

30.

How many times will line 4 be executed?

a)

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

b)

1

c)

10

d)

It is impossible to determine in advance

e)

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

31.

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

a)

10

b)

1

c)

It is impossible to determine in advance

d)

There is an error in the program, because line 5 should have been indented

32.

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

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

33.

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

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

34.

When this program is executed, what will be displayed on the screen after line 6 is executed and the user types 1357 on the keyboard?

a)

Wrong pin, try again

b)

Wrong pin, try again

Welcome

c)

Welcome

d)

Wrong pin, try again

Enter pin

35.

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

36.

The instructions in an algorithm___________________ .

a)

can be expressed in any language

b)

can be expressed in any language, as long as they are precise

c)

can only be expressed using a programming language

d)

can only be expressed using binary digits

37.

The instructions in an algorithm, when expressed precisely in English,__________________.

a)

can only be carried out by humans

b)

can only be carried out by computers

c)

can be carried out by both humans and computers

38.

The instructions in a program, when expressed in Python,_______________ .

a)

can only be carried out by humans, as long as they understand Python

b)

can only be carried out by computers

c)

can be carried out by computers, as long as an interpreter is available

d)

can be carried out by humans, as long as they understand Python, and computers, as long as an interpreter is available

39.

The instructions in a program________________.

a)

can be expressed in any language

b)

can be expressed in any language, as long as they are precise

c)

can only be expressed using a programming language

d)

can only be expressed using binary digits

40.

A Python program requires______________to be executed.

a)

a computer

b)

a program called 'the Python translator'

c)

a program called 'the Python interpreter'

d)

a program called 'a development environment'