Nighthawk Pages

Homeworks and Popcorn Hacks for Lessons

All homeworks for Lessons

Popcorn Hacks for 3.2

NumberOne= "enter number here"
NumberTwo= "enter number here"
Operation= "enter operation here"

if Operation == "+":
    print (NumberOne + NumberTwo)
if Operation == "-":
     print (NumberOne - NumberTwo)
if Operation == "*":
    print (NumberOne * NumberTwo)
if Operation == "/":
    print (NumberOne / NumberTwo)
def repeat_strings(strings, n):
    return [string * n for string in strings]

# Example usage
strings = ["apple", "grapes", "cherry"]
n = 3
result = repeat_strings(strings, n)
print(result)

def check_common_value(set1, set2):
    return any(value in set1 for value in set2)

set1 = {1, 2, 3, 4}
set2 = {5, 6, 3}
result = check_common_value(set1, set2)
print(result) 

True

Homework

profile = {
    "name": "Prajna",
    "age": 15,
    "city": "San Diego",
    "favorite_color": "Green"
}
print ("My profile:", profile)

hobbies= ["walking", "cooking", "playing music"]
print ("My hobbies!", hobbies)

profile["hobbies"] = hobbies
print ("My New Profile:", profile)

is_weather_good = True
has_hobby= is_weather_good
print (f"Is walking available today? {has_hobby}")

total_hobbies = 3
print (f"I have {total_hobbies} hobbies")

favorite_hobbies = ("Cooking", "Walking")
print ("My Favorites:", favorite_hobbies)

skills = {"Baking", "Singing"}
print ("My Skills:", skills)
profile["skills"] = skills

new_skill = None
print ("new skill:", new_skill)

total_cost = float(len(hobbies) * 3 + len(skills) * 2)
print (f"Costs for hobbies and skills: ${total_cost:.2f}")
My profile: {'name': 'Prajna', 'age': 15, 'city': 'San Diego', 'favorite_color': 'Green'}
My hobbies! ['walking', 'cooking', 'playing music']
My New Profile: {'name': 'Prajna', 'age': 15, 'city': 'San Diego', 'favorite_color': 'Green', 'hobbies': ['walking', 'cooking', 'playing music']}
Is walking available today? True
I have 3 hobbies
My Favorites: ('Cooking', 'Walking')
My Skills: {'Baking', 'Singing'}
new skill: None
Costs for hobbies and skills: $13.00
%%javascript

let profile = {
    name: "Prajna",
    age: 15,
    city: "San Diego",
    favorite_color: "Green"
};

console.log("My profile:", profile);

let hobbies = ["walking", "cooking", "playing music"];
console.log("My hobbies!", hobbies);

profile.hobbies = hobbies;
console.log("My New Profile:", profile);

let isWeatherGood = true;
let hasHobby = isWeatherGood;
console.log(`Is walking available today? ${hasHobby}`);

let totalHobbies = 3;
console.log(`I have ${totalHobbies} hobbies`);

let favoriteHobbies = ["Cooking", "Walking"];
console.log("My Favorites:", favoriteHobbies);

let skills = new Set(["Baking", "Singing"]);
console.log("My Skills:", Array.from(skills));

profile.skills = Array.from(skills);
console.log("My New Profile with skills:", profile);

let newSkill = null;
console.log("New skill:", newSkill);

let totalCost = (hobbies.length * 3) + (skills.size * 2);
console.log(`Costs for hobbies and skills: $${totalCost.toFixed(2)}`);
<IPython.core.display.Javascript object>

Extra Credit Quizziz:

<a href="https://docs.google.com/document/d/1YNEk4kr5aJC-7O54KntJXViz9h5lSeF1LD-Als5AdyI/edit?usp=sharing">Screenshot of Quizziz results</a>
Scroll to top