Lesson 3: If... Else Logic
Decisions are the heart of programming. Just like in life ("If it rains, I take an umbrella, else I wear a t-shirt"), programs also need to make choices.
In Python we use keywords if, else, and elif (else if).
Indentation: The Golden Rule
Python is the only language where spaces matter! Code inside the IF must be moved to the right (indented).
if age >= 18:
print("You are an adult")
else:
print("You are a minor")
Your Objective
We created a secret password variable. Write a program that checks if the password is
"Python123".
- Modify the
input_passwordvariable in the editor. - If it equals "Python123", print "Access Granted".
- Else, print "Access Denied".