Homeworks
Part 1:
Choose one from the three options to make a conditonal statement and if help is needed, use the Format at the bottom of the page.
Option 1: Grade Checker
Example for the grade checker:
“F” if the grade is below 60. “D” if the grade is between 60 and 69. “C” if the grade is between 70 and 79. “B” if the grade is between 80 and 89. “A” if the grade is 90 or above.
Option 2: Weather app
Example for a weather app:
If the weather is sunny, print: “It’s a great day to go outside!” If the weather is rainy, print: “Don’t forget your umbrella!” If the weather is snowy, print: “Stay warm and safe!”
Option 3: Character Health Status
Example for a character health status:
If the health is 0, print: “Your character is dead.” If the health is between 1 and 25, print: “Critical condition! Find a health pack!” If the health is between 26 and 75, print: “Your character is wounded. Be cautious.” If the health is above 75, print: “Your character is healthy and ready for action!”
Part 2:
Make another conditional statement with your idea.
Make any If-Then, If, or Then-If statements with different ideas.
Format:
%%js
let weather = "raining cats and dogs"; // Change this to your input or value
let location = "San Diego"
if (weather === "snow" && location === "San Diego") {
console.log("Wait, how is it snowing??? This should'nt be possible! Why? How???");
} else if (weather === "raining cats and dogs") {
console.log("Ah, what a nice day... wait, why are cats and dogs falling out of the sky?");
} else {
console.log("Just an average day with average weather... probably...");
}
<IPython.core.display.Javascript object>
After testing any of the options, revise it and make another one from the options.
%%js
let pokemon = "Ditto";
let hp = 100;
if (hp === 100){
console.log(`Yay! Your ${pokemon} is at full health!`);
} else if (hp >= 50){
console.log(`Your ${pokemon} doing pretty okay. It's not in any imminent danger.`);
} else if (hp >10) {
console.log(`Your ${pokemon} might be in danger soon... be careful!`);
} else {
console.log(`Wuh-oh, your ${pokemon} is close to fainting... you might want to switch it out.`)
}
<IPython.core.display.Javascript object>