Conditionals Python Homework


Python Popcorn Hack

number1 = 10
number2 = 0

if number2 != 0:
    result = number1 / number2
    print("The answer is", result)
else:
    print("Error: Cannot divide by zero!")

Part A: Answer the Question!

What does an if statement do in programming?

An if statement checks a condition. If the condition is true, it runs a block of code. If it’s false, it skips it.

Part B: Python Practice

Write a Python program that checks if a number score = 85 is a passing grade (≥ 60). Print “Pass” if true, otherwise "Fail".

# <-- Example Code

x = 19

if x >= 18:
    print("You can vote")
else:
    print("You are too young to vote")
# <-- Do the homework in this code cell
score = 85

if score >= 60:
    print("Pass")
else:
    print("Fail")

Pass