Popcorn Hack 1

weather = "sunny"
transportation = "available"
boots = "present"
hikelength = "long"

print("The weather is " + weather)
print("Your transportation is " + transportation)
print("Your boots are " + boots)
print("The length of the hike is " + hikelength)


if weather == "sunny":
    if transportation == "available":
        if boots == "present":
            if hikelength == "short":
                    print("You are ready to go hiking!")
            else:
                    print("You need to find a shorter trail. You will get too tired.")
        else:
            print("You need to find your boots first.")
    else:
        print("You need to arrange transportation.")
else:
    print("It's not good weather for hiking.")
The weather is sunny
Your transportation is available
Your boots are present
The length of the hike is long
You need to find a shorter trail. You will get too tired.

Popcorn Hack 2

%%js

let weather = "sunny";
let transportation = "available";
let boots = "present";
let hikelength = "long";

console.log("The weather is " + weather);
console.log("Your transportation is " + transportation);
console.log("Your boots are " + boots);
console.log("The length of the hike is " + hikelength);

if (weather === "sunny") {
    if (transportation === "available") {
        if (boots === "present") {
            if (hikelength === "short") {
                console.log("You are ready to go hiking!");
            } else {
                console.log("You need to find a shorter trail. You will get too tired.");
            }
        } else {
            console.log("You need to find your boots first.");
        }
    } else {
        console.log("You need to arrange transportation.");
    }
} else {
    console.log("It's not good weather for hiking.");
}
<IPython.core.display.Javascript object>

Python Homework Hacks

Hack 1: Write Python pseudocode to decide whether or not to go to the beach.

define weather define has_sunscreen define snack_count

If weather is sunny if has_sunscreen is True if snack_count is greater than or equal to 5 say “You are ready for beach” otherwise say “You should get more snacks” otherwise say “You should buy sunscreen” otherwise say “It isn’t a good day to go to the beach”

Hack 2: Write a Python code that checks if you can adopt a pet.

age = 19
house_sqft = 25
available_to_care = True

if age > 18:
    if house_sqft > 50:
        if available_to_care == True:
            print("You are eligible to adopt a pet.")
        else:
            print("You are not eligible to adopt a pet. You need to be available to care for the pet.")
    else:
        print("You are not eligible to adopt a pet. Your house is too small.")
else:
    print("You are not eligible to adopt a pet. You need to be over 18 years old.")
You are not eligible to adopt a pet. Your house is too small.

Hack 3: Write Python code to determine whether or not to participate in a marathon.

weather = "clear"
hasRunningShoes = True
daysPracticed = 3

if weather == "clear":
    if hasRunningShoes == True:
        if daysPracticed > 10:
            print("You are ready for the marathon!")
        else:
            print("You need to practice more.")
    else:
        print("You need to buy running shoes.")
else:
    print("You need clear weather to run a marathon.")
You need to practice more.

Javascript Homework Hacks

Hack 1: Write Javascript pseudocode to decide whether or not to study for an exam.

%%js

let hasStudyMaterials = true;
let hasQuietPlaceToStudy = true;
let tirenessLevel = 9;

if (hasStudyMaterials === true) {
    if (hasQuietPlaceToStudy === true) {
        if (tirenessLevel < 7) {
            console.log("You should study now.");
        } else {
            console.log("You are too tired to study.");
        }
    } else {
        console.log("You need a quiet place to study.");
    }
} else {
    console.log("You need to get study materials.");
}
<IPython.core.display.Javascript object>

Hack 2: Write Javascript code deciding whether or not you can bake a cake.

%%js

let bakingMaterials = "eggs, sugar, flour";
let oven = "working";
let time = 2;

if (bakingMaterials === "eggs, sugar, flour") {
    if (oven === "working") {
        if (time >= 1) {
            console.log("You can bake a cake.");
        } else {
            console.log("You need to allow more time for baking.");
        }
    } else {
        console.log("You need to fix the oven.");
    }
} else {
    console.log("You need to get baking materials.");
}
<IPython.core.display.Javascript object>

Hack 3: Write Javascript code to determine whether or not to go camping.

%%js

let weather = "clear";
let hasTent = true;
let hasEnoughFoodWater = false;

if (weather === "clear") {
    if (hasTent === true) {
        if (hasEnoughFoodWater === true) {
            console.log("You can go camping.");
        } else {
            console.log("You need to get more food and water.");
        }
    } else {
        console.log("You need to bring a tent.");
    }
} else {
    console.log("The weather is not good for camping.");
}
<IPython.core.display.Javascript object>