Fall 2024 - P1
Big Idea 3 | .1 | .2 | .3 | .4 | .5 | .6 | .7 | .8 | .10 |
3.2 Hacks
Hack #1
Create a list of data that could work with your GitHub Pages Blog Topic. For example, if your blog was about movies from different genres, make a list of movies for every genre.
# Define a dictionary with tech gadgets categorized by type
tech_gadgets = {
"Smartphones": ["iPhone 15", "Google Pixel 8", "Samsung Galaxy S23"],
"Laptops": ["MacBook Air", "Dell XPS 13", "Microsoft Surface Laptop 5"],
"Wearables": ["Apple Watch Series 9", "Fitbit Charge 5", "Garmin Fenix 7"],
"Headphones": ["Sony WH-1000XM5", "Bose QuietComfort 45", "AirPods Pro 2"]
}
# Function to print the list of gadgets by category
def print_gadgets(gadgets):
for category, items in gadgets.items():
print(f"\n{category}:")
for item in items:
print(f" - {item}")
# Call the function to display gadgets
print_gadgets(tech_gadgets)
Hack #2
Try creating a dictionary for your github homepage that contains what was within each sprint.
For example, in Sprint 1, we had frontend development, github pages playgroud, and javascript playground.
sprints = {
'Sprint1': ['Frontend Development', 'Github Pages Playground', 'Javascript Playground'],
'Sprint2': ['Big Ideas 3.2']
}
print(sprints['Sprint1'])
if "Frontend Development" in sprints['Sprint1']:
print(True)
else:
print(False)
# Output:
# ['Frontend Development', 'Github Pages Playground', 'Javascript Playground']
# True
Hack #3
- Try to create a mix of list and dictionaries to represent a real world collection of data
- The system i created is a Library System
# List of dictionaries representing books in a library
library = [
{
"title": "The Six of Crow",
"author": "Leigh Bardugo",
"genre": "Fantasy",
"copies_available": 2,
"borrowers": [
{"name": "Katherine Chen", "borrow_date": "2024-09-10"},
{"name": "Aditi Bandaru", "borrow_date": "2024-09-15"}
]
},
{
"title": "A Game of Thrones",
"author": "George R.R. Martin",
"genre": "Action",
"copies_available": 1,
"borrowers": [
{"name": "Soni Dhenuva", "borrow_date": "2024-09-08"}
]
},
{
"title": "Percy Jackson : The Last Olympian",
"author": "Rick Riordan",
"genre": "Adventure",
"copies_available": 0,
"borrowers": [
{"name": "Sanya Kapoor", "borrow_date": "2024-09-05"},
]
}
]
# Display information about each book in the library
for book in library:
print(f"Title: {book['title']}")
print(f"Author: {book['author']}")
print(f"Genre: {book['genre']}")
print(f"Copies Available: {book['copies_available']}")
print("Borrowers:")
for borrower in book['borrowers']:
print(f" - {borrower['name']} (Borrowed on: {borrower['borrow_date']})")
print("\n")