Boolean Expressions and Logic Homework
Quick practice with Boolean Expressions and Logic
Booleans Extra Homework
1. Movie Night Decision
is_raining = False
homework_done = True
if not is_raining and homework_done:
print("You can go to the movies!")
else:
print("Stay home tonight.")
You can go to the movies!
2. Discount Eligibility
is_student = False
age = 16
if is_student or age < 18:
print("You get a student discount!")
else:
print("Sorry, no discount.")
You get a student discount!
3. Secure Login
%%js
let username = "admin";
let password = "1234";
if (username === "admin" && password === "1234") {
console.log("Login successful!");
} else {
console.log("Access denied.");
}
4. Battery and Power Check
%%js
let pluggedIn = false;
let batteryPercent = 65;
if (pluggedIn || batteryPercent >= 50) {
console.log("You can play the game!");
} else {
console.log("Charge your device first.");
}