What is IPO?
Input Process Output
Which Python structure allows a program to choose between different paths?
An if/elif/else decision structure
Which loop is normally the best choice when we know the number of repetitions there will be?
What keyword is used to define a function in Python?
def
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
Why does it have {}?
name = "Juan"
print(f"Hello, {name}")
Cause it is an f string
What does this print?
age = 16
has_permission = True
if age >= 18 and has_permission:
print("Access granted")
else:
print("Access denied")
Access denied
How many times is "Hello" printed?
for i in range(1, 5):
print("Hello")
4
What is the difference between Testing and Debugging?
The first one looks for existing errors and the other one is correcting those errors
What does this print?
score = 70
if score > 70:
print("Pass")
else:
print("Try again")
Try again
What does this print?
price = 40
quantity = 3
total = price * quantity
print(total)
120
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.
Why is this an infinite loop?
count = 1
while count <= 5:
print(count)
count never changes, so the condition remains true
What is an argument or parameter in a function?
def greet(name):
The requirement says:
Unlock the level when the score is at least 100.
if score > 100:
print("Unlocked")
Where should it be corrected?
>=
What could be the error?
age = input("Enter your age: ")
next_age = age + 1
add int(input("Enter your age: "))
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
What does this program print at the end?
total = 0
for number in range(1, 4):
total = total + number
print(total)
6
What value is stored in result?
def multiply(a, b):
return a * b
result = multiply(4, 3)
12
What does this print?
def excuse(day):
return "My code worked yesterday"
print(excuse("Monday"))
"My code worked yesterday"
What does this print?
minutes = 135
hours = minutes // 60
remaining_minutes = minutes % 60
print(hours, remaining_minutes)
2 15
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
Tell me every number printed and explain the final number:
number = 10
while number > 0:
number = number - 3
print(number)
7 4
1 -2
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"
What will this print?
def add_drama(text):
return text + "!"
message = "BUG"
for i in range(3):
message = add_drama(message)
print(message)
BUG!!!