Popcorn Hack #1
bestDictionaryEver = {"porsche": 1, "mclaren": 2, "koenigsegg ": 3}
print(bestDictionaryEver["porsche"])
1
Popcorn Hack #2
firstNumber = input("Please Enter the First Number Here: ")
secondNumber = input("Please Enter the Second Number Here: ")
mathFunction = input("Please Enter the function here: ")
if mathFunction == "+":
print(firstNumber + secondNumber)
elif mathFunction == "-":
print(firstNumber - secondNumber)
elif mathFunction == "*":
print(firstNumber * secondNumber)
elif mathFunction == "/":
print(firstNumber / secondNumber)
Popcorn Hack #3
def repeat_strings_in_list(strings, n):
result = []
for string in strings:
result.append(string * n)
return result
string_list = ["uno", "dos", "tres"]
print(repeat_strings_in_list(string_list, 3))
['unounouno', 'dosdosdos', 'trestrestres']
Popcorn Hack #4
Homework 1
profile = {
"name": "Daksha",
"age": 16,
"city": "San Diego",
"favorite_color": "white"
}
print("Profile:", profile)
Profile: {'name': 'Daksha', 'age': 16, 'city': 'San Diego', 'favorite_color': 'white'}
Homeowkr 2
hobbies = ["Efootball", "sports", "sparring"]
print("Hobbies:", hobbies)
Hobbies: ['Efootball', 'sports', 'sparring']
Homeowkr 3
profile["hobbies"] = hobbies
print("Updated Profile:", profile)
Updated Profile: {'name': 'Daksha', 'age': 16, 'city': 'San Diego', 'favorite_color': 'white', 'hobbies': ['Efootball', 'sports', 'sparring']}
Homework 4
has_hobby = True
print(f"Is {hobbies[0]} available today? {has_hobby}")
Is Efootball available today? True
Homework 5
total_hobbies = len(hobbies)
print(f"I have {total_hobbies} hobbies.")
I have 3 hobbies.
Homework 6
favorite_hobbies = ("Sports", "TV")
print("Favorite Hobbies:", favorite_hobbies)
Favorite Hobbies: ('Sports', 'TV')
Homework 7
skills = {"Cooking", "Fighting", "Sleeping"}
print("Skills:", skills)
Skills: {'Sleeping', 'Fighting', 'Cooking'}
Homework 8
new_skill = None
print("New Skill:", new_skill)
New Skill: None
Homework 9
total_cost = float(total_hobbies * 8 + len(skills) * 6)
print(f"Total cost to pursue hobbies and skills: ${total_cost:.2f}")
Total cost to pursue hobbies and skills: $42.00