3.2 Homework Hacks
Mihir's Submission for Homework Hacks
Homework
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.
# Liverpool FC Data System
liverpool_fc_data = {
# String, List, Dictionary
"players": {
"forwards": ["Mohamed Salah", "Darwin Núñez", "Diogo Jota", "Luis Díaz"],
"midfielders": ["Alexis Mac Allister", "Dominik Szoboszlai", "Curtis Jones", "Ryan Gravenberch"],
"defenders": ["Virgil van Dijk", "Ibrahima Konaté", "Trent Alexander-Arnold", "Andrew Robertson"],
"goalkeepers": ["Alisson Becker", "Caoimhin Kelleher"]
},
# Dictionary with Integer and String
"matches": {
"upcoming": {
"Premier League": "Liverpool vs Manchester United",
"date": "2024-10-15",
"stadium": "Anfield"
},
"last_match": {
"opponent": "Chelsea",
"score": "2-1",
"date": "2024-09-30"
}
},
# Set
"trophies": {
"Premier League", "FA Cup", "Champions League", "League Cup", "Community Shield"
},
# Tuple
"stadium_details": ("Anfield", 1884, 53000), # (name, year_built, capacity)
# List of dictionaries
"coaching_staff": [
{"name": "Jürgen Klopp", "role": "Manager"},
{"name": "Pepijn Lijnders", "role": "Assistant Manager"},
{"name": "Peter Krawietz", "role": "Assistant Manager"}
],
# Boolean
"in_champions_league": True,
# Float and Integer
"team_value": 2.7, # in billion USD
"number_of_players": 25,
}
# Function to display Liverpool FC Data
def print_liverpool_fc_data(data):
print("Liverpool FC Data Overview:\n")
# Displaying players
print("Players by Position:")
for position, players in data["players"].items():
print(f" {position.capitalize()}: {', '.join(players)}")
# Displaying match details
print("\nUpcoming Match:")
upcoming = data["matches"]["upcoming"]
print(f" {upcoming['Premier League']} at {upcoming['stadium']} on {upcoming['date']}")
print("\nLast Match:")
last_match = data["matches"]["last_match"]
print(f" vs {last_match['opponent']}, Score: {last_match['score']}, Date: {last_match['date']}")
# Displaying trophies
print("\nTrophies Won:")
print(f" {', '.join(data['trophies'])}")
# Displaying stadium details
print("\nStadium Details:")
stadium_name, year_built, capacity = data["stadium_details"]
print(f" {stadium_name}, Built in {year_built}, Capacity: {capacity}")
# Displaying coaching staff
print("\nCoaching Staff:")
for coach in data["coaching_staff"]:
print(f" {coach['name']} - {coach['role']}")
# Displaying Champions League status
print("\nChampions League Participation:")
print(f" {'Yes' if data['in_champions_league'] else 'No'}")
# Displaying team value and number of players
print("\nTeam Value and Squad Size:")
print(f" Team Value: ${data['team_value']} Billion")
print(f" Number of Players: {data['number_of_players']}\n")
# Call the function to display Liverpool FC data
print_liverpool_fc_data(liverpool_fc_data)
Liverpool FC Data Overview:
Players by Position:
Forwards: Mohamed Salah, Darwin Núñez, Diogo Jota, Luis Díaz
Midfielders: Alexis Mac Allister, Dominik Szoboszlai, Curtis Jones, Ryan Gravenberch
Defenders: Virgil van Dijk, Ibrahima Konaté, Trent Alexander-Arnold, Andrew Robertson
Goalkeepers: Alisson Becker, Caoimhin Kelleher
Upcoming Match:
Liverpool vs Manchester United at Anfield on 2024-10-15
Last Match:
vs Chelsea, Score: 2-1, Date: 2024-09-30
Trophies Won:
Premier League, Champions League, Community Shield, FA Cup, League Cup
Stadium Details:
Anfield, Built in 1884, Capacity: 53000
Coaching Staff:
Jürgen Klopp - Manager
Pepijn Lijnders - Assistant Manager
Peter Krawietz - Assistant Manager
Champions League Participation:
Yes
Team Value and Squad Size:
Team Value: $2.7 Billion
Number of Players: 25