# We have apples and bananas. We want to give at least one fruit to each friend.
# Do we have enough fruits? Are the apples enough? Are the bananas?
apples = 10
bananas = 5
friends = 15
if (apples + bananas) >= friends:
print("We have enough fruits for our friends!")
elif apples >= friends:
print("We have enough apples for our friends!")
elif bananas >= friends:
print("We have enough bananas for our friends!")
else:
print("We don't have enough fruit for our friends!")Review: Flow Control
Module 1: Python Fundamentals
Review of Session 1.2: Flow Control
Exercise
Which of the following if statements will never happen?
Exercise
What is going to be the final value of x?
x = 5
condition = x**2 < 10
if condition:
x = x + 1
else:
x = x + 3
x = x / 2
print(x)
Exercise
Without running the code, what is going to be the output of this cell?
years = "5"
if years > 0:
print(f"I am {years} years old")
Exercise
Look at the following piece of code and explain why it fails.
# Exercise 2.2
# Create a code that checks if a number a is divisible by another b. The output
# should be a message like ÔÇ£(a) is divisible by (b)ÔÇØ
a = 10
b = 2
# Expected output: Yes
# (a, b) are divisible if the remainder of a/b is 0
if a % b = 0:
print(f"{a} is divisible by {b}")