Sequential Structures
Decision Structures
Repetition Structures
Functions and Testing
Mixed Questions
100

What is IPO?

Input Process Output

100

Which Python structure allows a program to choose between different paths?

An if/elif/else decision structure

100

Which loop is normally the best choice when we know the number of repetitions there will be?

A FOR loop
100

What keyword is used to define a function in Python?

def

100

A student copied this line 100 times: 

print("I will not procrastinate")

Which programming structure could have saved him from this truly tragic decision?

A FOR loop

200

Why does it have {}?

name = "Juan"

print(f"Hello, {name}")

Cause it is an f string

200

What does this print?

age = 16

has_permission = True

if age >= 18 and has_permission:

    print("Access granted")

else:

    print("Access denied")

Access denied

200

How many times is "Hello" printed?

for i in range(1, 5):

    print("Hello")

4

200

What is the difference between Testing and Debugging?

The first one looks for existing errors and the other one is correcting those errors

200

What does this print?
score = 70

if score > 70:

    print("Pass")

else:

    print("Try again")

Try again

300

What does this print?

price = 40

quantity = 3

total = price * quantity


print(total)

120

300

What does this program print, and why?

temperature = 30

if temperature >= 20:

    print("Warm")

elif temperature >= 30:

    print("Hot")

else:

    print("Cold")

 

Warm

Cause Python executes the first true condition. The Hot condition is never reached. 

300

Why is this an infinite loop?

count = 1

while count <= 5:

    print(count)

count never changes, so the condition remains true

300

What is an argument or parameter in a function?

The info that you ask the user to enter to use the function:

def greet(name):

300

The requirement says:

Unlock the level when the score is at least 100.

if score > 100:

    print("Unlocked")

Where should it be corrected?

>=

400

What could be the error?

age = input("Enter your age: ")

next_age = age + 1

add int(input("Enter your age: "))

400

What is wrong with this decision structure? 

if grade >= 70:

    print("Pass")

elif grade >= 90:

    print("Excellent")

The Excellent branch can never execute because a grade of 90 already satisfies grade >= 70

400

What does this program print at the end?

total = 0

for number in range(1, 4):

    total = total + number

print(total)

6

400

What value is stored in result?

def multiply(a, b):

    return a * b

result = multiply(4, 3)

12

400

What does this print?

def excuse(day):

    return "My code worked yesterday"

print(excuse("Monday"))

"My code worked yesterday"

500

What does this print?

minutes = 135

hours = minutes // 60

remaining_minutes = minutes % 60


print(hours, remaining_minutes)

2 15

500

What does this program print?

has_id = True

age = 17

with_adult = False

if has_id and (age >= 18 or with_adult):

    print("Enter")

else:

    print("Wait")

Wait

500

Tell me every number printed and explain the final number:

number = 10

while number > 0:

    number = number - 3

    print(number)

7 4
1 -2

500

What does this program print? 

def add_two(number):

    return number + 2

x = 1

for i in range(3):

    x = add_two(x)

print(x)

1 then 3 then 5 then 7

It prints "7"

500

What will this print?

def add_drama(text):

    return text + "!"

message = "BUG"

for i in range(3):

    message = add_drama(message)

print(message)

BUG!!!