wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Grade 12-Python selection&iteration

Total questions: 15

Worksheet time: 26mins

Name
Class
Date
1.

In programming, what is iteration?

a)

The repetition of steps within a program

b)

The order in which instructions are carried out

c)

A decision point in a program

d)

Testing a program to make sure it works

2.

Which two statements are used to implement iteration?

a)

IF and WHILE

b)

ELSE and WHILE

c)

FOR and WHILE

d)

IF and ELSE

3.

The condition for a while loop to continue could include which of the following?

a)

While something equals something

b)

While something is greater than something

c)

While something is True

d)

All of these

4.

number=number-1

a)

5

4

3

2

1

b)

4

3

2

1

0

c)

5 4 3 2 1

d)

4 3 2 1 0

5.
a)

10 8 6 4 2

b)

10

8

6

4

2

c)

2 4 6 8 10

d)

10 9 8 7 6 5 4 3 2 1

6.
a)

12 17 22

b)

5

c)

12

d)

5 10

7.
a)

Hello world!

b)

Hello world

c)

Hello world!

Hello world!

Hello world!

Hello world!

Hello world!

Hello world!

......(repeated continuously)

d)

Error

8.

Which of these is NOT a loop in python?

a)

for loop

b)

while loop

c)

nested loop

d)

if loop

9.

What is the error in this code?

a)

incorrect variable name

b)

incorrect indentation

c)

incorrect speech marks

d)

incorrect loop

10.

If you want more than one option for your code, what do you use (after if)?

a)

elif

b)

elseif

c)

else

11.

people = ["John", "Rob", "Bob"]

print (people[1])

what would this result be?

a)

John

b)

Rob

c)

Bob

12.

What is the result of the code:

team = Cowboys

if team = Cowboys:

print "Dallas is #1"

a)

team

b)

Cowboys

c)

Error

d)

Dallas is #1

13.

Suppose you want to determine if a student is ready to graduate. The 3 criteria for graduation are that the student has earned at least 120 credits, their major GPA is at least 3.0 or their general GPA is also at least 3.5

Which Boolean expression would be the correct test for Python code?

a)

numCredits >= 120 and majorGPA >= 3.0 or overallGPA >= 3.5

b)

numCredits > 120 and majorGPA > 3.0 and overallGPA >3.5

c)

numCredits > =119 and majorGPA >= 3.0 and overallGPA >= 3.5

14.

Write the line of code which initialize the counter variable

a)

x<20

b)

x=x+1

c)

name=input("Enter your name")

d)

x=0

15.

In the above program if the value of 'x' is 23 and 'number' is 24, what will be the output?

a)

23 24

b)

23

c)

23

24

d)

3 4