Exercise 1: Introduction to Conditionals
Welcome to conditionals in Python! Conditionals are statements that allow your program to make decisions based on certain conditions.
What are Conditionals?
Conditionals are simply statements that say if something happens, the computer must do this; otherwise, the computer should do something else.
Here's a simple example of how conditionals work:
There are three types of conditional statements:
- If statement: The if statement starts off the conditional.
- Elif statement: This is the middle, it says that if the previous conditions didn't happen, but this one does, then do the following function.
- Else statement: This ends the conditional, saying that if nothing above happened, then do the following.
Now it's your turn! Complete the Python program that uses if and else statements to check if a person's credit score is high enough to qualify for a loan.
# This program checks if the person's credit score is high enough to qualify for a loan.
credit_score = 800
if credit_score > 600:
print("You get the loan!")
# TODO - write the else statement
Write your code here
Make it print You get the loan!
Did it work?
Your program should print this:
You get the loan!