Python Nested Conditionals Hacks Below

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

Meet the following conditions:

The weather must be sunny.
You must have sunscreen.
You must have enough snacks.

If all conditions are met, output a message that says you are ready for the beach.
If you don’t have enough snacks, suggest getting snacks first.
If you don’t have sunscreen, suggest buying sunscreen.
If the weather is not sunny, output that it’s not a good day for the beach.
Hack 2: Write a Python code that checks if you can adopt a pet.

Include the following conditions:

You must be 18 years or older.
You must have enough space in your home (more than 50 square feet).
You must be available to take care of the pet (true/false).

If all conditions are true, print that you can adopt the pet.
If you don’t have enough space, print that you need a bigger home.
If you aren’t available to take care of the pet, print that you need to make time.
If you are not 18 or older, print that you must be at least 18 to adopt a pet.
Hack 3: Write Python code to determine whether or not to participate in a marathon.

Check the following conditions:

The weather must be clear.
You must have running shoes.
You must have practiced for at least 10 days.

If all conditions are met, print that you are ready for the marathon.
If you don’t have running shoes, print that you need to buy shoes first.
If you haven’t practiced enough, print that you need to practice more.
If the weather is not clear, print that it’s not the right time for the marathon.

Python Quiz

Question 1:

What will be the output of the following code?

let age = 16;
let hasPermission = false;

if (age >= 18) {
    if (hasPermission) {
        console.log("You can enter.");
    } else {
        console.log("You need permission to enter.");
    }
} else {
    console.log("You are too young to enter.");
}

A. You can enter. B. You need permission to enter. C. You are too young to enter.

Question 2:

Given the following code, what will be printed if x = 10 and y = -5?

let x = 10;
let y = -5;

if (x > 0) {
    if (y > 0) {
        console.log("Both x and y are positive.");
    } else {
        console.log("x is positive but y is not.");
    }
} else {
    console.log("x is not positive.");
}

A. Both x and y are positive. B. x is positive but y is not. C. x is not positive.

Question 3:

What will be the output of the following code?

let temperature = 65;
let isSunny = true;

if (temperature > 70) {
    if (isSunny) {
        console.log("It's a nice day for a picnic.");
    } else {
        console.log("It's warm but not sunny.");
    }
} else {
    console.log("It's too cold.");
}

A. It’s a nice day for a picnic. B. It’s warm but not sunny. C. It’s too cold.