Big Idea 3 Section 7

Popcorn Hack #1

age = int(input("Enter your age: "))
likes_sweets = input("Do you want to get your drivers license? Type yes or no: ").lower()

if age >= 16:
    if likes_sweets == "yes":
        print("Alright, you can start your driving lessons!")
    else:
        print("Why don't you want to get your drivers license?")
else:
    print("You are not old enough.")
You are not old enough.
%%js

let age = parseInt(18);
let wantsLicense = "yes";

if (age >= 16) {
    if (wantsLicense === "yes") {
        console.log("Alright, you can start your driving lessons!");
    } else {
        console.log("Why don't you want to get your drivers license?");
    }
} else {
    console.log("You are not old enough.");
}
<IPython.core.display.Javascript object>

Popcorn Hack #2

money = 373

jacket_price = 24
shirt_price = 18
jeans_price = 33

if money >= jacket_price:
    print("You can buy the jacket!")
elif money >= shirt_price:
    print("You can buy the shirt!")
elif money >= jeans_price:
    print("You can buy the jeans!")
else:
    print("You don't have enough money to buy clothing.")
You can buy the jacket!

Popcorn Hack #3

%%js
let is_school_open = true;
let want_to_go_to_school = false;

if (is_school_open) {
    console.log("School is open.");

    if (want_to_go_to_school) {
        console.log("You can go to school.");
    } else {
        console.log("You can skip school.");
    }
} else {
    console.log("You can stay home because its a holiday.");
}
<IPython.core.display.Javascript object>

Homework 1

child_age = int(input("Whats your age?: "))
child_has_ball = input("Do you have a ball? Type yes or no: ").lower()

if child_age >= 5 and child_has_ball == "yes":
    if child_age < 8:
        message = "You can play with the younger kids."
    else:
        message = "You can play with the older kids."

    print(f"Great! {message}")
else:
    print("Sorry, you can't join the game yet.")
Great! You can play with the older kids.