Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 157 additions & 0 deletions exercise_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#1. Manchester United FC has hired you as a developer. Develop a program that helps the coach identify their fastest player, player with the most goals,
#assists, passing accuracy, and defensive involvements.
#The system should also allow comparison between two players. Use the following player profiles:
#
#Bruno Fernandes: 5 goals, 6 points in speed, 9 points in assists, 10 points in passing accuracy, 3 defensive involvements. Corresponds to jersey number 8.
#Rasmus Hojlund: 12 goals, 8 points in speed, 2 points in assists, 6 points in passing accuracy, 2 defensive involvements. Corresponds to jersey number 11.
#Harry Maguire: 1 goal, 5 points in speed, 1 point in assists, 7 points in passing accuracy, 9 defensive involvements. Corresponds to jersey number 5.
#Alejandro Garnacho: 8 goals, 7 points in speed, 8 points in assists, 6 points in passing accuracy, 0 defensive involvements. Corresponds to jersey number 17.
#Mason Mount: 2 goals, 6 points in speed, 4 points in assists, 8 points in passing accuracy, 1 defensive involvement. Corresponds to jersey number 7.
#The program functions as follows: The coach accesses the system and encounters a menu with the following options:
#
#Player Review: By entering the player's jersey number, they can access the player's characteristics.
#Compare two players: The system prompts for two jersey numbers and displays the data of both players on screen.
#Identify the fastest player: Displays the player with the most points in speed.
#Identify the top goal scorer: Displays the player with the most points in goals.
#Identify the player with the most assists: Displays the player with the most points in assists.
#Identify the player with the highest passing accuracy: Displays the player with the most points in passing accuracy.
#Identify the player with the most defensive involvements: Displays the player with the most points in defensive involvements.
#The system should also allow returning to the main menu.

#building data dictionari

profiles = {
8: {
'name': 'Bruno Fernandes',
'goals': 5,
'speed': 6,
'assists': 9,
'passing accuracy': 10,
'defensive involvements': 3
},
11: {
'name': 'Rasmus Hojlund',
'goals': 12,
'speed': 8,
'assists': 2,
'passing accuracy': 6,
'defensive involvements': 2
},
5: {
'name': 'Harry Maguire',
'goals': 1,
'speed': 5,
'assists': 1,
'passing accuracy': 7,
'defensive involvements': 9
},
17: {
'name': 'Alejandro Garnacho',
'goals': 8,
'speed': 7,
'assists': 8,
'passing accuracy': 6,
'defensive involvements': 0
},
7: {
'name': 'Mason Mount',
'goals': 2,
'speed': 6,
'assists': 4,
'passing accuracy': 8,
'defensive involvements': 1
}
}

#function to display the menu
def display_menu():
print("Welcome to the Manchester United FC player review system.")
print("Please select an option:")
print("1. Player Review")
print("2. Compare two players")
print("3. Identify the fastest player")
print("4. Identify the top goal scorer")
print("5. Identify the player with the most assists")
print("6. Identify the player with the highest passing accuracy")
print("7. Identify the player with the most defensive involvements")
print("8. Return to the main menu")

while True:
display_menu()
option = input("Enter your option: ")

if option == "1":
#Player Review
jersey_number = int(input("Enter the player's jersey number: "))
player_profile = profiles.get(jersey_number)
if player_profile:
print("**********************************************************************")
print("Player Profile:")
print("Name:", player_profile['name'])
print("Goals:", player_profile['goals'])
print("Speed:", player_profile['speed'])
print("Assists:", player_profile['assists'])
print("Passing Accuracy:", player_profile['passing accuracy'])
print("Defensive Involvements:", player_profile['defensive involvements'])
print("**********************************************************************")
else:
print("Player not found.")
elif option == "2":
#Compare two players
jersey_number1 = int(input("Enter the first player's jersey number: "))
player_profile1 = profiles.get(jersey_number1)
jersey_number2 = int(input("Enter the second player's jersey number: "))
player_profile2 = profiles.get(jersey_number2)
if player_profile1 and player_profile2:
print("**********************************************************************")
print("Player Profile 1:")
print("Name:", player_profile1['name'])
print("Goals:", player_profile1['goals'])
print("Speed:", player_profile1['speed'])
print("Assists:", player_profile1['assists'])
print("Passing Accuracy:", player_profile1['passing accuracy'])
print("Defensive Involvements:", player_profile1['defensive involvements'])
print("Player Profile 2:")
print("Name:", player_profile2['name'])
print("Goals:", player_profile2['goals'])
print("Speed:", player_profile2['speed'])
print("Assists:", player_profile2['assists'])
print("Passing Accuracy:", player_profile2['passing accuracy'])
print("Defensive Involvements:", player_profile2['defensive involvements'])
print("**********************************************************************")
else:
print("One or both players not found.")
elif option == "3":
#Identify the fastest player
fastest_player = max(profiles, key=lambda x: profiles[x]['speed'])
print("**********************************************************************")
print("The fastest player is", profiles[fastest_player]['name'], "with", profiles[fastest_player]['speed'], "points in speed.")
print("**********************************************************************")
elif option == "4":
#Identify the top goal scorer
top_scorer = max(profiles, key=lambda x: profiles[x]['goals'])
print("**********************************************************************")
print("The top goal scorer is", profiles[top_scorer]['name'], "with", profiles[top_scorer]['goals'], "goals.")
print("**********************************************************************")
elif option == "5":
#Identify the player with the most assists
most_assists = max(profiles, key=lambda x: profiles[x]['assists'])
print("**********************************************************************")
print("The player with the most assists is", profiles[most_assists]['name'], "with", profiles[most_assists]['assists'], "assists.")
print("**********************************************************************")
elif option == "6":
#Identify the player with the highest passing accuracy
highest_passing_accuracy = max(profiles, key=lambda x: profiles[x]['passing accuracy'])
print("**********************************************************************")
print("The player with the highest passing accuracy is", profiles[highest_passing_accuracy]['name'], "with a passing accuracy of", profiles[highest_passing_accuracy]['passing accuracy'], "points.")
print("**********************************************************************")
elif option == "7":
#Identify the player with the most defensive involvements
most_defensive_involvements = max(profiles, key=lambda x: profiles[x]['defensive involvements'])
print("**********************************************************************")
print("The player with the most defensive involvements is", profiles[most_defensive_involvements]['name'], "with", profiles[most_defensive_involvements]['defensive involvements'], "defensive involvements.")
print("**********************************************************************")
else:
print("Invalid option. Please try again.")


150 changes: 150 additions & 0 deletions exercise_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#2. A travel agency has a special offer for traveling in any season of 2024. Their destinations are:
#
#Winter: Andorra and Switzerland. In Andorra, there are skiing activities, and in Switzerland, there's a tour of the Swiss Alps.
#Summer: Spain and Portugal. In Spain, there are hiking and extreme sports activities. In Portugal, there are activities on the beaches.
#Spring: France and Italy. In France, there are extreme sports activities, and in Italy, there's a cultural and historical tour.
#Autumn: Belgium and Austria. In Belgium, there are hiking and extreme sports activities, and in Austria, there are cultural and historical activities.
#Note: Traveling in winter costs $100, in autumn $200, in spring $300, and in summer $400.
#
#Design a system that helps users choose their best destination according to their personal preferences and the season they want to travel in.
#12. Important: With the information you have, you should ask the user the right questions and display on screen what their best destination would be.
#
#Clue: You could consider the user's budget

destinations = {
"Winter": {
"Andorra": {
"cost": 100,
"activities": ["skiing"]
},
"Switzerland": {
"cost": 100,
"activities": ["tour of the Alps"]
}
},
"Summer": {
"Spain": {
"cost": 400,
"activities": ["hiking"]
},
"Portugal": {
"cost": 300,
"activities": ["beaches"]
}
},
"Spring": {
"France": {
"cost": 300,
"activities": ["extreme sports"]
},
"Italy": {
"cost": 200,
"activities": ["cultural and historical tour"]
}
},
"Autumn": {
"Belgium": {
"cost": 200,
"activities": ["hiking"]
},
"Austria": {
"cost": 200,
"activities": ["cultural and historical activities"]
}
}
}

def get_user_input():
print("Welcome to the travel agency!")
print("Please enter your budget:")
budget = int(input())
if budget < 0:
print("Invalid budget")
return None
elif budget < 100:
print("You should consider a higher budget")
elif budget >= 100 and budget < 200:
print("You can choice Winter")
elif budget >= 200 and budget < 300:
print("You can choice Winter and Spring")
elif budget >= 300 and budget < 400:
print("You can choice Winter, Spring and Summer")
elif budget >= 400:
print("You can choice all seasons")
print("Please enter your season:")
season = input()
return budget, season

def personal_preferences(season):
if season == "Winter":
print("What activities would you prefer?")
print("1. Skiing")
print("2. Tour of the Alps")

while True:
preference = int(input("Enter your preference: "))
if preference == 1:
print("You should go to Andorra")
break
if preference == 2:
print("You should go to Switzerland")
break
else:
print("Invalid choice")
if season == "Autumn":
print("What activities would you prefer?")
print("1. Hiking and extreme sports")
print("2. Cultural and Historical activities")

while True:
preference = int(input("Enter your preference: "))
if preference == 1:
print("You should go to Belgium")
break
if preference == 2:
print("You should go to Austria")
break
else:
print("Invalid choice")

if season == "Spring":
print("What activities would you prefer?")
print("1. Extreme sports")
print("2. Cultural and historical tour")

while True:
preference = int(input("Enter your preference: "))
if preference == 1:
print("You should go to France")
break
if preference == 2:
print("You should go to Italy")
break
else:
print("Invalid choice")
if season == "Summer":
print("What activities would you prefer?")
print("1. Hiking and extreme sports")
print("2. Activities on the Beache")

while True:
preference = int(input("Enter your preference: "))
if preference == 1:
print("You should go to Spain")
break
if preference == 2:
print("You should go to Portugal")
break
else:
print("Invalid choice")



while True:
user_input = get_user_input()
if user_input:
budget, season = user_input
personal_preferences(season)

print("Thanks for your preference")
break
Loading