# Python Popcorn Hack 1: Sets
set_a = {1, 2, 3, 4, 5}
### 1. Adding 6 to the Set
set_a.add(6)
print(set_a) # Output: {1, 2, 3, 4, 5, 6}
set_a.remove(2) #removing 2
set_b = {7, 8, 9} #new set
union_set = set_a.union(set_b) #union of sets
union_set.clear() #clears set
# Print the set to confirm it's empty
print(union_set)
# Create a set with duplicates
my_set = {1, 2, 2, 3, 3, 4}
# Find the length of the set
set_length = len(my_set)
# Print the length of the set
print(set_length)
Gaheera Rhea Hannah Rowan
Bananas are soft and sweet. They are great as a snack or in banana bread and smoothies. They are excellent sources of potassium.
#Python Popcorn Hack 4: Dictionaries
# Step 1: Create the personal_info dictionary
personal_info = {
"name": "Gaheera Babbar",
"email": "gaheerababbar20@gmail.com",
"phone number": "8584425370"
}
# Step 2: Print the entire dictionary
print("Personal Information Dictionary:", personal_info)
# Step 3: Print the name from the dictionary
print("My Name is:", personal_info["name"])
# Step 4: Print the length of the dictionary
print("The length of the dictionary is:", len(personal_info))
# Step 5: Print the type of the dictionary
print("The type of the dictionary is:", type(personal_info))
# Bonus: Create another dictionary and print their different values
friend_info = {
"name": "Jane Smith",
"email": "janesmith@example.com",
"phone number": "987-654-3210"
}
# Print values from both dictionaries
print("\nMy Information:")
print("Name:", personal_info["name"])
print("Email:", personal_info["email"])
print("Phone Number:", personal_info["phone number"])
print("\nFriend's Information:")
print("Name:", friend_info["name"])
print("Email:", friend_inf
#Python Homework Hack
#Part 1: Personal Info
personal_info = { "full_name": "Bob Smith", "years": 35, "location": "New Jersey", "favorite_food": "Hot Dogs" }
print(personal_info)
#Part 2: Activities
activities = ["Fishing", "Hiking", "Gaming"]
print(activities)
#Part 3: Add activities to personal info
personal_info["activities"] = activities
print(personal_info)
#Part 4: Available Activity
activity_available = True
print(f"Is Gaming available today? {activity_available}")
# Part 5: Calculate the total number of activities
total_activities = len(activities)
print(f"I have {total_activities} activities.")
#Part 6: Favorite Activities
favorite_activities = ("Fishing", "Hiking")
print(favorite_activities)
#Part 7: New Set of Skills
skills = {"Python", "Cooking", "Oragami"}
print(skills)
# Part 8: Create a variable for a new skill, set to None
new_skill = None
print(new_skill)
#Part 9: Total Cost
total_cost = (len(activities) * 5) + (len(skills) * 10)
print(f"Total cost: ${total_cost}")
%%js
//Javascript Popcorn Hack 1: Sets
// Create Set1 with 3 numbers
let Set1 = new Set([1, 2, 3]);
// Create Set2 with 3 different numbers
let Set2 = new Set([4, 5, 6]);
// Log both sets
console.log("Set1:", Set1);
console.log("Set2:", Set2);
// Add a number to Set1
Set1.add(7);
// Remove the first number (1) from Set1
Set1.delete(1);
// Log Set1 after modification
console.log("Set1 after adding 7 and removing 1:", Set1);
// Get the union of Set1 and Set2
let unionSet = new Set([...Set1, ...Set2]);
// Log the union of Set1 and Set2
console.log("Union of Set1 and Set2:", unionSet);
<IPython.core.display.Javascript object>
%%js
// Javascript Popcorn Hack 2: Dictionaries
// Create the dictionary (object) called "application"
let application = {
name: "Bob Smith",
age: 30,
experiences: ["Software Engineer", "Project Manager", "Consultant"],
money: 5000
};
// Log the entire dictionary to make sure it works
console.log("Application:", application);
// Log only the dictionary's money
console.log("Money:", application.money);
<IPython.core.display.Javascript object>
%%js
// Javascript Homework Hack
// Create an empty object to store the applicant's information
let application = {};
// Prompt the user for their name, age, and experiences
application.name = prompt("What is your name?");
application.age = prompt("How old are you?");
application.experiences = prompt("What are your experiences? (Separate multiple experiences by commas)").split(',');
// Log the user's input (the entire application object)
console.log("Applicant's Information:", application);
// Log each individual input
console.log("Name:", application.name);
console.log("Age:", application.age);
console.log("Experiences:", application.experiences);
<IPython.core.display.Javascript object>