HW Question 1
# Prompts user to enter age
user_age= int(input("What is your age?"))
# Will determine whether the user is old enough to vote.
if user_age >= 18:
print("You are old enough to Vote!")
else:
print("You are not able to vote. You must be at least 18 years old")
Quick Quiz 1
What would the function output if the user’s age was 16?
You aren’t old enough to vote
When the age of the user is greater than 18, what is the condition in the if statement?
You are old enough to vote
What is the purpose of the if statement in the function?
To see if you are old enough to vote.
HW Question 2
%%html
// Ask user input
let user_health = prompt("Are you healthy, unhealthy, or indifferent about food?");
if (user_health === "healthy") {
console.log("Treat yourself to chocolate!");
} else {
// Check for the other conditions within the else block
if (user_health === "unhealthy") {
console.log("You need to eat some fruits and vegetables!");
} else {
console.log("You can eat whatever you like");
}
}
Quick Quiz 2
What would the function output if the user’s age was not healthy?
You need to eat some fruits and vegtables!
When the age of the user is unhealthy, what is the condition in the if statement?
You can eat whatever you like