From d35454e910fc6a1d35621d308c256f5b12ed59a2 Mon Sep 17 00:00:00 2001 From: Daniel Tamayo Date: Sun, 7 Jan 2024 19:45:44 -0500 Subject: [PATCH 1/7] First challenge completed --- ElyRiven/01_.py/01_PlayersSystem.py | 183 ++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 ElyRiven/01_.py/01_PlayersSystem.py diff --git a/ElyRiven/01_.py/01_PlayersSystem.py b/ElyRiven/01_.py/01_PlayersSystem.py new file mode 100644 index 0000000..dea869c --- /dev/null +++ b/ElyRiven/01_.py/01_PlayersSystem.py @@ -0,0 +1,183 @@ +# 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. +# ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +PLAYERS = [ + { + 'name': 'Bruno Fernandes', + 'jersey': 8, + 'goals': 5, + 'speed': 6, + 'assists': 9, + 'passing accuracy': 10, + 'defensive involvements': 3 + }, + { + 'name': 'Rasmus Hojlund', + 'jersey': 11, + 'goals': 12, + 'speed': 8, + 'assists': 2, + 'passing accuracy': 6, + 'defensive involvements': 2 + }, + { + 'name': 'Harry Maguire', + 'jersey': 5, + 'goals': 1, + 'speed': 5, + 'assists': 1, + 'passing accuracy': 7, + 'defensive involvements': 9 + }, + { + 'name': 'Alejandro Garnacho', + 'jersey': 17, + 'goals': 8, + 'speed': 7, + 'assists': 8, + 'passing accuracy': 6, + 'defensive involvements': 0 + }, + { + 'name': 'Mason Mount', + 'jersey': 7, + 'goals': 2, + 'speed': 6, + 'assists': 4, + 'passing accuracy': 8, + 'defensive involvements': 1 + } +] + +def main(): + while True: + choice = showMenu() + if choice == 8: + exit() + elif choice == 1: + player = getJerseyNumber() + if player != None: + reviewPlayer(player) + continue + elif choice == 2: + print("First Player --------") + player1 = getJerseyNumber() + if player1 != None: + print("Second Player --------") + player2 = getJerseyNumber() + if player2 != None: + comparePlayers(player1, player2) + else: + continue + else: + continue + elif choice == 3: + fastestPlayer() + pass + elif choice == 4: + topGoalScorer() + pass + elif choice == 5: + mostAssists() + pass + elif choice == 6: + highestPassingAccuracy() + pass + elif choice == 7: + mostDefensiveInvolvements() + pass + +def mostDefensiveInvolvements(): + for player in PLAYERS: + if player['defensive involvements'] == max(player['defensive involvements'] for player in PLAYERS): + print(f"\nThe player with the most defensive involvements is {player.get('name')} with {player.get('defensive involvements')} defensive involvements\n") + +def highestPassingAccuracy(): + for player in PLAYERS: + if player['passing accuracy'] == max(player['passing accuracy'] for player in PLAYERS): + print(f"\nThe player with the highest passing accuracy is {player.get('name')} with {player.get('passing accuracy')} passing accuracy\n") + +def mostAssists(): + for player in PLAYERS: + if player['assists'] == max(player['assists'] for player in PLAYERS): + print(f"\nThe player with the most assists is {player.get('name')} with {player.get('assists')} assists\n") + +def topGoalScorer(): + for player in PLAYERS: + if player['goals'] == max(player['goals'] for player in PLAYERS): + print(f"\nThe top goal scorer is {player.get('name')} with {player.get('goals')} goals\n") + +def fastestPlayer(): + for player in PLAYERS: + if player['speed'] == max(player['speed'] for player in PLAYERS): + print(f"\nThe fastest player is {player.get('name')} with {player.get('speed')} speed points\n") + +def comparePlayers(player1, player2): + print("\n\t\tPlayer Comparison") + print(f"{player1.get('name')} | {player2.get('name')}\n") + print(f"Jersey Number: {player1.get('jersey')} | {player2.get('jersey')}") + print(f"Goals: {player1.get('goals')} | {player2.get('goals')}") + print(f"Speed Points: {player1.get('speed')} | {player2.get('speed')}") + print(f"Assists: {player1.get('assists')} | {player2.get('assists')}") + print(f"Passing Accuracy: {player1.get('passing accuracy')} | {player2.get('passing accuracy')}") + print(f"Defensive Involvements: {player1.get('defensive involvements')} | {player2.get('defensive involvements')}") + +def getJerseyNumber(): + try: + number = int(input("Enter the player's jersey number: ")) + for player in PLAYERS: + if player['jersey'] == number: + return player + else: + continue + print(f"There is no player with the jersey number {number}\n") + except: + print("Invalid input\n") + +def reviewPlayer(player): + print(f"\nName: {player.get('name')}\n") + print(f"Jersey Number: {player.get('jersey')}\n") + print(f"Goals: {player.get('goals')}\n") + print(f"Speed Points: {player.get('speed')}\n") + print(f"Assists: {player.get('assists')}\n") + print(f"Passing Accuracy: {player.get('passing accuracy')}\n") + print(f"Defensive Involvements: {player.get('defensive involvements')}\n\n") + +def showMenu(): + print("\t\tWelcome to the Player's System\n\n") + print("1. Player Review\n") + print("2. Compare two players\n") + print("3. Identify the fastest player\n") + print("4. Identify the top goal scorer\n") + print("5. Identify the player with the most assists\n") + print("6. Identify the player with the highest passing accuracy\n") + print("7. Identify the player with the most defensive involvements\n") + print("8. Exit\n") + try: + choice = int(input(">> ")) + if choice < 1 or choice > 8: + print("Invalid input\n") + else: + return choice if type(choice) == int else print("Invalid input\n") + except: + print("Invalid input\n") + +if __name__ == "__main__": + main() \ No newline at end of file From 9783bab62fafecb3879caf1754e968659f2b01fb Mon Sep 17 00:00:00 2001 From: Daniel Tamayo Date: Mon, 8 Jan 2024 14:05:12 -0500 Subject: [PATCH 2/7] Removed unnecesary forlder --- ElyRiven/01_.py/01_PlayersSystem.py | 183 ---------------------------- 1 file changed, 183 deletions(-) delete mode 100644 ElyRiven/01_.py/01_PlayersSystem.py diff --git a/ElyRiven/01_.py/01_PlayersSystem.py b/ElyRiven/01_.py/01_PlayersSystem.py deleted file mode 100644 index dea869c..0000000 --- a/ElyRiven/01_.py/01_PlayersSystem.py +++ /dev/null @@ -1,183 +0,0 @@ -# 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. -# ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -PLAYERS = [ - { - 'name': 'Bruno Fernandes', - 'jersey': 8, - 'goals': 5, - 'speed': 6, - 'assists': 9, - 'passing accuracy': 10, - 'defensive involvements': 3 - }, - { - 'name': 'Rasmus Hojlund', - 'jersey': 11, - 'goals': 12, - 'speed': 8, - 'assists': 2, - 'passing accuracy': 6, - 'defensive involvements': 2 - }, - { - 'name': 'Harry Maguire', - 'jersey': 5, - 'goals': 1, - 'speed': 5, - 'assists': 1, - 'passing accuracy': 7, - 'defensive involvements': 9 - }, - { - 'name': 'Alejandro Garnacho', - 'jersey': 17, - 'goals': 8, - 'speed': 7, - 'assists': 8, - 'passing accuracy': 6, - 'defensive involvements': 0 - }, - { - 'name': 'Mason Mount', - 'jersey': 7, - 'goals': 2, - 'speed': 6, - 'assists': 4, - 'passing accuracy': 8, - 'defensive involvements': 1 - } -] - -def main(): - while True: - choice = showMenu() - if choice == 8: - exit() - elif choice == 1: - player = getJerseyNumber() - if player != None: - reviewPlayer(player) - continue - elif choice == 2: - print("First Player --------") - player1 = getJerseyNumber() - if player1 != None: - print("Second Player --------") - player2 = getJerseyNumber() - if player2 != None: - comparePlayers(player1, player2) - else: - continue - else: - continue - elif choice == 3: - fastestPlayer() - pass - elif choice == 4: - topGoalScorer() - pass - elif choice == 5: - mostAssists() - pass - elif choice == 6: - highestPassingAccuracy() - pass - elif choice == 7: - mostDefensiveInvolvements() - pass - -def mostDefensiveInvolvements(): - for player in PLAYERS: - if player['defensive involvements'] == max(player['defensive involvements'] for player in PLAYERS): - print(f"\nThe player with the most defensive involvements is {player.get('name')} with {player.get('defensive involvements')} defensive involvements\n") - -def highestPassingAccuracy(): - for player in PLAYERS: - if player['passing accuracy'] == max(player['passing accuracy'] for player in PLAYERS): - print(f"\nThe player with the highest passing accuracy is {player.get('name')} with {player.get('passing accuracy')} passing accuracy\n") - -def mostAssists(): - for player in PLAYERS: - if player['assists'] == max(player['assists'] for player in PLAYERS): - print(f"\nThe player with the most assists is {player.get('name')} with {player.get('assists')} assists\n") - -def topGoalScorer(): - for player in PLAYERS: - if player['goals'] == max(player['goals'] for player in PLAYERS): - print(f"\nThe top goal scorer is {player.get('name')} with {player.get('goals')} goals\n") - -def fastestPlayer(): - for player in PLAYERS: - if player['speed'] == max(player['speed'] for player in PLAYERS): - print(f"\nThe fastest player is {player.get('name')} with {player.get('speed')} speed points\n") - -def comparePlayers(player1, player2): - print("\n\t\tPlayer Comparison") - print(f"{player1.get('name')} | {player2.get('name')}\n") - print(f"Jersey Number: {player1.get('jersey')} | {player2.get('jersey')}") - print(f"Goals: {player1.get('goals')} | {player2.get('goals')}") - print(f"Speed Points: {player1.get('speed')} | {player2.get('speed')}") - print(f"Assists: {player1.get('assists')} | {player2.get('assists')}") - print(f"Passing Accuracy: {player1.get('passing accuracy')} | {player2.get('passing accuracy')}") - print(f"Defensive Involvements: {player1.get('defensive involvements')} | {player2.get('defensive involvements')}") - -def getJerseyNumber(): - try: - number = int(input("Enter the player's jersey number: ")) - for player in PLAYERS: - if player['jersey'] == number: - return player - else: - continue - print(f"There is no player with the jersey number {number}\n") - except: - print("Invalid input\n") - -def reviewPlayer(player): - print(f"\nName: {player.get('name')}\n") - print(f"Jersey Number: {player.get('jersey')}\n") - print(f"Goals: {player.get('goals')}\n") - print(f"Speed Points: {player.get('speed')}\n") - print(f"Assists: {player.get('assists')}\n") - print(f"Passing Accuracy: {player.get('passing accuracy')}\n") - print(f"Defensive Involvements: {player.get('defensive involvements')}\n\n") - -def showMenu(): - print("\t\tWelcome to the Player's System\n\n") - print("1. Player Review\n") - print("2. Compare two players\n") - print("3. Identify the fastest player\n") - print("4. Identify the top goal scorer\n") - print("5. Identify the player with the most assists\n") - print("6. Identify the player with the highest passing accuracy\n") - print("7. Identify the player with the most defensive involvements\n") - print("8. Exit\n") - try: - choice = int(input(">> ")) - if choice < 1 or choice > 8: - print("Invalid input\n") - else: - return choice if type(choice) == int else print("Invalid input\n") - except: - print("Invalid input\n") - -if __name__ == "__main__": - main() \ No newline at end of file From 5390ee6af6d8ee5e3bd2102dd172cf95bfa9b0b4 Mon Sep 17 00:00:00 2001 From: Daniel Tamayo Date: Mon, 8 Jan 2024 14:06:06 -0500 Subject: [PATCH 3/7] Second challenge completed --- ElyRiven/01_PlayersSystem.py | 182 +++++++++++++++++++++++++++++++++++ ElyRiven/02_TravelAgency.py | 118 +++++++++++++++++++++++ 2 files changed, 300 insertions(+) create mode 100644 ElyRiven/01_PlayersSystem.py create mode 100644 ElyRiven/02_TravelAgency.py diff --git a/ElyRiven/01_PlayersSystem.py b/ElyRiven/01_PlayersSystem.py new file mode 100644 index 0000000..9f175b1 --- /dev/null +++ b/ElyRiven/01_PlayersSystem.py @@ -0,0 +1,182 @@ +# 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. + +PLAYERS = [ + { + 'name': 'Bruno Fernandes', + 'jersey': 8, + 'goals': 5, + 'speed': 6, + 'assists': 9, + 'passing accuracy': 10, + 'defensive involvements': 3 + }, + { + 'name': 'Rasmus Hojlund', + 'jersey': 11, + 'goals': 12, + 'speed': 8, + 'assists': 2, + 'passing accuracy': 6, + 'defensive involvements': 2 + }, + { + 'name': 'Harry Maguire', + 'jersey': 5, + 'goals': 1, + 'speed': 5, + 'assists': 1, + 'passing accuracy': 7, + 'defensive involvements': 9 + }, + { + 'name': 'Alejandro Garnacho', + 'jersey': 17, + 'goals': 8, + 'speed': 7, + 'assists': 8, + 'passing accuracy': 6, + 'defensive involvements': 0 + }, + { + 'name': 'Mason Mount', + 'jersey': 7, + 'goals': 2, + 'speed': 6, + 'assists': 4, + 'passing accuracy': 8, + 'defensive involvements': 1 + } +] + +def main(): + while True: + choice = showMenu() + if choice == 8: + exit() + elif choice == 1: + player = getJerseyNumber() + if player != None: + reviewPlayer(player) + continue + elif choice == 2: + print("First Player --------") + player1 = getJerseyNumber() + if player1 != None: + print("Second Player --------") + player2 = getJerseyNumber() + if player2 != None: + comparePlayers(player1, player2) + else: + continue + else: + continue + elif choice == 3: + fastestPlayer() + pass + elif choice == 4: + topGoalScorer() + pass + elif choice == 5: + mostAssists() + pass + elif choice == 6: + highestPassingAccuracy() + pass + elif choice == 7: + mostDefensiveInvolvements() + pass + +def mostDefensiveInvolvements(): + for player in PLAYERS: + if player['defensive involvements'] == max(player['defensive involvements'] for player in PLAYERS): + print(f"\nThe player with the most defensive involvements is {player.get('name')} with {player.get('defensive involvements')} defensive involvements\n") + +def highestPassingAccuracy(): + for player in PLAYERS: + if player['passing accuracy'] == max(player['passing accuracy'] for player in PLAYERS): + print(f"\nThe player with the highest passing accuracy is {player.get('name')} with {player.get('passing accuracy')} passing accuracy\n") + +def mostAssists(): + for player in PLAYERS: + if player['assists'] == max(player['assists'] for player in PLAYERS): + print(f"\nThe player with the most assists is {player.get('name')} with {player.get('assists')} assists\n") + +def topGoalScorer(): + for player in PLAYERS: + if player['goals'] == max(player['goals'] for player in PLAYERS): + print(f"\nThe top goal scorer is {player.get('name')} with {player.get('goals')} goals\n") + +def fastestPlayer(): + for player in PLAYERS: + if player['speed'] == max(player['speed'] for player in PLAYERS): + print(f"\nThe fastest player is {player.get('name')} with {player.get('speed')} speed points\n") + +def comparePlayers(player1, player2): + print("\n\t\tPlayer Comparison") + print(f"{player1.get('name')} | {player2.get('name')}\n") + print(f"Jersey Number: {player1.get('jersey')} | {player2.get('jersey')}") + print(f"Goals: {player1.get('goals')} | {player2.get('goals')}") + print(f"Speed Points: {player1.get('speed')} | {player2.get('speed')}") + print(f"Assists: {player1.get('assists')} | {player2.get('assists')}") + print(f"Passing Accuracy: {player1.get('passing accuracy')} | {player2.get('passing accuracy')}") + print(f"Defensive Involvements: {player1.get('defensive involvements')} | {player2.get('defensive involvements')}") + +def getJerseyNumber(): + try: + number = int(input("Enter the player's jersey number: ")) + for player in PLAYERS: + if player['jersey'] == number: + return player + else: + continue + print(f"There is no player with the jersey number {number}\n") + except: + print("Invalid input\n") + +def reviewPlayer(player): + print(f"\nName: {player.get('name')}\n") + print(f"Jersey Number: {player.get('jersey')}\n") + print(f"Goals: {player.get('goals')}\n") + print(f"Speed Points: {player.get('speed')}\n") + print(f"Assists: {player.get('assists')}\n") + print(f"Passing Accuracy: {player.get('passing accuracy')}\n") + print(f"Defensive Involvements: {player.get('defensive involvements')}\n\n") + +def showMenu(): + print("\t\tWelcome to the Player's System\n\n") + print("1. Player Review\n") + print("2. Compare two players\n") + print("3. Identify the fastest player\n") + print("4. Identify the top goal scorer\n") + print("5. Identify the player with the most assists\n") + print("6. Identify the player with the highest passing accuracy\n") + print("7. Identify the player with the most defensive involvements\n") + print("8. Exit\n") + try: + choice = int(input(">> ")) + if choice < 1 or choice > 8: + print("Invalid input\n") + else: + return choice if type(choice) == int else print("Invalid input\n") + except: + print("Invalid input\n") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/ElyRiven/02_TravelAgency.py b/ElyRiven/02_TravelAgency.py new file mode 100644 index 0000000..9ea7fd5 --- /dev/null +++ b/ElyRiven/02_TravelAgency.py @@ -0,0 +1,118 @@ +# 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 + +TRAVELDESTINATIONS = { + "winter": { + "andorra": "Skying activities", + "switzerland": "Tour of the Swiss Alps" + }, + "summer": { + "spain": "Hiking and extreme sports activities", + "portugal": "Activities on the beaches" + }, + "spring": { + "france": "Extreme sports activities", + "italy": "Cultural and historical tour" + }, + "autumn": { + "belgium": "Hiking and extreme sports activities", + "austria": "Cultural and historical activities" + } +} + +def main(): + print("\t\tWelcome to our travel agency!\n\n") + budget = getBudget() + if budget != None: + print(f"Your budget is: ${budget}") + season = getSeason(budget) + if season != None: + print(f"Your season is: {season}") + destination = getActivity(season) + if type(destination) != str: + print("Since you have no preferences, we can offer you to travel to these beautiful destinations:\n") + for country, activity in destination.items(): + print(f"Country - {country.title()}\t Activities - {activity}") in destination + else: + print(f"Your best destination based on your preferences is: {destination.title()}") + print("\nThank you for using our travel agency!") + +def travelSuggestion(season, activity): + print(f"Your travel suggestion is: {TRAVELDESTINATIONS[season]}") + +# Ask for the activity of preference +def getActivity(season): + x = 1 + activity1 = "" + activity2 = "" + print("What is your activity of preference? Select one of the following\n") + for key in TRAVELDESTINATIONS[season]: + print(f"{x}. {TRAVELDESTINATIONS[season][key]}") + if x == 1: + activity1 = TRAVELDESTINATIONS[season][key] + if x == 2: + activity2 = TRAVELDESTINATIONS[season][key] + x += 1 + print(f"{x}. No preference") + try: + option = int(input(">> ")) + if option == 3: + return TRAVELDESTINATIONS[season] + elif option == 1: + return getDestination(season, activity1) + elif option == 2: + return getDestination(season, activity2) + except: + print("Invalid input.") + +def getDestination(season, activity): + for inner_key, inner_value in TRAVELDESTINATIONS[season].items(): + if inner_value == activity: + return inner_key + +def seasonRecommend(budget): + if budget <= 100: + return "Winter" + elif budget <= 200: + return "Autumn" + elif budget <= 300: + return "Spring" + elif budget <= 400: + return "Summer" + else: + return "Summer" + +def getSeason(budget): + try: + recomendation = seasonRecommend(budget) + print(f"\nSeasons Available\nWinter - Spring - Summer - Autumn | RECOMMENDED SEASON -> {recomendation}\n") + season = input(">> ").lower() + if season in TRAVELDESTINATIONS: + return season + else: + print("Invalid input.") + except: + print("Invalid input.") + +def getBudget(): + try: + budget = float(input("Enter your budget: $")) + if budget > 0: + return budget + else: + print("Invalid input.") + except: + print("Invalid input.") + +if __name__ == "__main__": + main() \ No newline at end of file From b66f075356b813ec0983af92ffd87206959b3ee6 Mon Sep 17 00:00:00 2001 From: Daniel Tamayo Date: Fri, 12 Jan 2024 17:45:30 -0500 Subject: [PATCH 4/7] Third Challenge Completed --- ElyRiven/03_HospitalSystem.py | 161 ++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 ElyRiven/03_HospitalSystem.py diff --git a/ElyRiven/03_HospitalSystem.py b/ElyRiven/03_HospitalSystem.py new file mode 100644 index 0000000..40f17a8 --- /dev/null +++ b/ElyRiven/03_HospitalSystem.py @@ -0,0 +1,161 @@ +# 3.The Valencia Hospital is developing an application to manage appointments. Design an algorithm for this application with the following features: + +# It must have a login and validate the data; after the third failed attempt, it should be locked. +# The user can schedule an appointment for: General Medicine, Emergency Care, Clinical Analysis, Cardiology, Neurology, Nutrition, Physiotherapy, Traumatology, and Internal Medicine. +# There are 3 doctors for each specialty. +# The user can only book one appointment per specialist. An error message should be displayed if the user tries to choose two appointments with the same doctor or the same specialty. As a developer, you can choose the doctors' names. +# The maximum limit for appointments, in general, is 3. +# Upon selecting a specialty, it will display if the user prefers a morning or afternoon appointment and show available hours. As a developer, you can choose the hours. +# Display available specialists. +# The user can choose their preferred specialist. +# The basic process is: Login -> Choose specialty -> Choose doctor -> Choose time slot. + +USERDATA = { + 'username': 'e', + 'password': 'e' +} +AVAILABLE_SCHEDULE = ["morning - 08:00", "afternoon - 16:30"] + +DOCTORS = { + "general medicine": ["Dr. A", "Dr. B", "Dr. C"], + "emergency care": ["Dr. A", "Dr. B", "Dr. C"], + "clinical analysis": ["Dr. G", "Dr. H", "Dr. I"], + "cardiology": ["Dr. J", "Dr. K", "Dr. L"], + "neurology": ["Dr. M", "Dr. N", "Dr. O"], + "nutrition": ["Dr. P", "Dr. Q", "Dr. R"], + "physiotherapy": ["Dr. S", "Dr. T", "Dr. U"], + "traumatology": ["Dr. V", "Dr. W", "Dr. X"], + "internal medicine": ["Dr. Y", "Dr. Z", "Dr. AA"], +} + +def main(): + attempts = 3 + loggedUser = User("","") + print("\t\tWelcome to Valencia Hospital\n\n") + while attempts > 0: + print("Please login with your credentials:") + user, passw = login() + if (user != None and passw != None): + print("Login successful") + loggedUser.username = user + loggedUser.password = passw + break + else: + attempts -= 1 + print(f"\nAttempts left {attempts}") + else: + print("System Locked out") + while not False: + specialty = getSpecialty() + if specialty == None: + break + else: + doctor = showDoctor(specialty) + if doctor != None: + print(f"You have chosen {doctor} as your doctor") + schedule = getSchedule() + if schedule != None: + if loggedUser.checkAppointment(doctor,specialty): + print("You already have an appointment") + else: + if loggedUser.addAppointment(doctor,specialty,schedule): + print(f"Appointment added: {doctor} {specialty} {schedule}") + else: + print("Appointment limit exceeded") + else: + print("Invalid input") + +def getSpecialty(): + specialty = "" + print("\n\nChoose one specialty\n") + print("1. General Medicine\n2. Emergency Care\n3. Clinical Analysis\n4. Cardiology\n5. Neurology\n6. Nutrition\n7. Physiotherapy\n8. Traumatology\n9. Internal Medicine\n0. Exit") + try: + option = int(input(">> ")) + if option == 0: + return None + if option == 1: + specialty = "general medicine" + if option == 2: + specialty = "emergency care" + if option == 3: + specialty = "clinical analysis" + if option == 4: + specialty = "cardiology" + if option == 5: + specialty = "neurology" + if option == 6: + specialty = "nutrition" + if option == 7: + specialty = "physiotherapy" + if option == 8: + specialty = "traumatology" + if option == 9: + specialty = "internal medicine" + return specialty + except: + print("Invalid input") + +def getSchedule(): + print("Available schedules: ") + for i in range(len(AVAILABLE_SCHEDULE)): + print(f"{i+1}. {AVAILABLE_SCHEDULE[i]}") + try: + option = int(input(">> ")) + return AVAILABLE_SCHEDULE[option-1] + except: + print("Invalid input") + +def getDoctor(specialty): + doctors = DOCTORS[specialty] + for i in range(len(doctors)): + print(f"{i+1}. {doctors[i]}") + try: + option = int(input(">> ")) + return doctors[option-1] + except: + print("Invalid input") + +def showDoctor(specialty): + print("Choose one doctor: ") + selection = getDoctor(specialty) + return selection + + +def login(): + try: + user = input("Username: ") + if user == USERDATA['username']: + passw = input("Password: ") + if passw == USERDATA['password']: + return user, passw + else: + print("Invalid password") + else: + print("Invalid username") + return None, None + except: + print("Invalid input") + +class User: + appointmentIndex = 0 + def __init__(self, username, password, appointments = {}): + self.username = username + self.password = password + self.appointments = appointments + + def addAppointment(self, doctor, specialty, schedule): + if len(self.appointments) < 3: + self.appointments[self.appointmentIndex] = [doctor,specialty,schedule] + self.appointmentIndex += 1 + return True + else: + return False + + def checkAppointment(self, doctor, specialty): + for appointment in self.appointments.values(): + if appointment[0] == doctor or appointment[1] == specialty: + return True + return False + +if __name__ == "__main__": + main() \ No newline at end of file From fdee3492ff3b05333f25baf3dfe8ca51aa26d980 Mon Sep 17 00:00:00 2001 From: Daniel Tamayo Date: Mon, 15 Jan 2024 16:32:05 -0500 Subject: [PATCH 5/7] Fourth challenge completed --- ElyRiven/03_HospitalSystem.py | 4 +- ElyRiven/04_RHHotels.py | 292 ++++++++++++++++++++++++++++++++++ 2 files changed, 294 insertions(+), 2 deletions(-) create mode 100644 ElyRiven/04_RHHotels.py diff --git a/ElyRiven/03_HospitalSystem.py b/ElyRiven/03_HospitalSystem.py index 40f17a8..39cebe4 100644 --- a/ElyRiven/03_HospitalSystem.py +++ b/ElyRiven/03_HospitalSystem.py @@ -11,8 +11,8 @@ # The basic process is: Login -> Choose specialty -> Choose doctor -> Choose time slot. USERDATA = { - 'username': 'e', - 'password': 'e' + 'username': 'elyriven', + 'password': 'pass123' } AVAILABLE_SCHEDULE = ["morning - 08:00", "afternoon - 16:30"] diff --git a/ElyRiven/04_RHHotels.py b/ElyRiven/04_RHHotels.py new file mode 100644 index 0000000..784fff0 --- /dev/null +++ b/ElyRiven/04_RHHotels.py @@ -0,0 +1,292 @@ +# 4. The RH Hotels chain has hired you to design the booking algorithm for their mobile application: + +# Login; it should be locked after the third failed attempt. +# The RH Hotels chain exists in 5 countries: Spain, France, Portugal, Italy, and Germany. +# Each country has its own hotels located in: Madrid, Barcelona, Valencia, Munich, Berlin, Rome, Milan, Paris, Marseille, Madeira, Lisbon, and Porto. +# All hotels have 24 rooms each: 6 VIP suites, 3 single rooms, 6 double rooms, 6 group rooms, and 3 luxury suites. +# The user can make reservations at any time of the year and at any hour, and book as many rooms as desired. +# Single rooms are priced at $100 per night, double rooms at $200 per night, group rooms at $350 per night, VIP suites at $450 per night, and luxury suites at $550 per night, applicable at any time of the year. +# The algorithm functions as follows: Login, choose country, choose city, choose room type, select the number of nights, collect user data (name, surname, ID/passport), +# print the total cost, and if the user agrees, print a confirmation message for the reservation. If not, return to the main menu. + +USERDATA = { + 'username': 'e', + 'password': 'e' +} + +Spain_Hotels = [ + { + "madrid": { + "single": 3, + "double": 6, + "group": 6, + "vip": 6, + "luxury": 3, + } + }, + { + "barcelona": { + "single": 3, + "double": 6, + "group": 6, + "vip": 6, + "luxury": 3, + } + }, + { + "valencia": { + "single": 3, + "double": 6, + "group": 6, + "vip": 6, + "luxury": 3, + } + } +] + +France_Hotels = [ + { + "paris": { + "single": 3, + "double": 6, + "group": 6, + "vip": 6, + "luxury": 3, + } + }, + { + "marseille": { + "single": 3, + "double": 6, + "group": 6, + "vip": 6, + "luxury": 3, + } + } +] + +Portugal_Hotels = [ + { + "madeira": { + "single": 3, + "double": 6, + "group": 6, + "vip": 6, + "luxury": 3, + } + }, + { + "lisbon": { + "single": 3, + "double": 6, + "group": 6, + "vip": 6, + "luxury": 3, + } + }, + { + "porto": { + "single": 3, + "double": 6, + "group": 6, + "vip": 6, + "luxury": 3, + } + }, +] + +Italy_Hotels = [ + { + "rome": { + "single": 3, + "double": 6, + "group": 6, + "vip": 6, + "luxury": 3, + } + }, + { + "milan": { + "single": 3, + "double": 6, + "group": 6, + "vip": 6, + "luxury": 3, + } + } +] + +Germany_Hotels = [ + { + "munich": { + "single": 3, + "double": 6, + "group": 6, + "vip": 6, + "luxury": 3, + } + }, + { + "berlin": { + "single": 3, + "double": 6, + "group": 6, + "vip": 6, + "luxury": 3, + } + } +] + +ROOM_PRICES = { + "single": 100, + "double": 200, + "group": 350, + "vip": 450, + "luxury": 550, +} + +def main(): + attempt = 3 + print("\t\tWelcome to RH Hotels\n\n") + while attempt > 0: + print("Please login with your credentials") + user, passw = login() + if (user != None and passw != None): + print("Login successful") + break + else: + attempt -= 1 + print(f"\nAttempts left {attempt}") + else: + print("System Locked out") + while True: + country, hotels = getCountry() + city, rooms = getCity(hotels) + roomType, cost = getRoomType(rooms) + nights = getNights() + userData = getUserInfo() + reservation = [country, city, roomType, nights, cost * nights] + print(f"\nReservation details:\n\nCountry: {reservation[0].title()}\nCity: {reservation[1].title()}\nRoom type: {reservation[2].title()}\nNights: {reservation[3]}\nTotal cost: ${reservation[4]}\n") + if confirmReservation(city, roomType): + print("Reservation confirmed") + continue + else: + print("Reservation cancelled") + break + +# Ask the user to confirm the reservation +def confirmReservation(selectedCity, roomType): + countries = [Spain_Hotels, France_Hotels, Portugal_Hotels, Italy_Hotels, Germany_Hotels] + while True: + confirm = input("Do you want to confirm the reservation? (y/n): ").lower() + if confirm == "y": + for hotels in countries: + for i, hotel in enumerate(hotels): + if selectedCity in hotel: + hotel[selectedCity][roomType] -= 1 + return True + else: + continue + elif confirm == "n": + return False + else: + print("Invalid input\n") + +# Ask the user information +def getUserInfo(): + name = input("Please enter your name: ") + surname = input("Please enter your surname: ") + id = input("Please enter your ID/Passport: ") + return [name, surname, id] + +# Ask the number of nights +def getNights(): + while True: + try: + nights = int(input("Please enter the number of nights: ")) + if nights > 0: + return nights + else: + print("Invalid number of nights\n") + except ValueError: + print("Invalid input\n") + +# Ask the desired room type +def getRoomType(rooms): + while True: + print("Please select a room type") + for i, available in enumerate(list(rooms.items())): + print(f"{i+1}. {available[0].title()} - {available[1]} available") + try: + room_index = int(input(">> ")) - 1 + if 0 <= room_index < len(rooms): + selectedRoom = list(rooms.keys())[room_index] + if rooms[selectedRoom] > 0: + return selectedRoom, ROOM_PRICES[selectedRoom] + else: + print(f"Type room {selectedRoom.title()} is not available\n") + else: + print("Invalid room type\n") + except ValueError: + print("Invalid input\n") + +# Ask the desired city and return the list of rooms available +def getCity(availableHotels): + while True: + print("Please select a city") + for i, hotel in enumerate(availableHotels): + city = list(hotel.keys())[0] + print(f"{i+1}. {city.title()}") + try: + city_index = int(input(">> ")) - 1 + if 0 <= city_index < len(availableHotels): + selectedCity = list(availableHotels[city_index].keys())[0] + return selectedCity, availableHotels[city_index][selectedCity] + else: + print("Invalid city\n") + except ValueError: + print("Invalid input\n") + +# Ask the desired country and return the list of hotels available +def getCountry(): + while True: + print("Please select a country") + print("1. Spain") + print("2. France") + print("3. Portugal") + print("4. Italy") + print("5. Germany") + try: + country = int(input(">> ")) + if country == 1: + return "Spain", Spain_Hotels + elif country == 2: + return "France", France_Hotels + elif country == 3: + return "Portugal", Portugal_Hotels + elif country == 4: + return "Italy", Italy_Hotels + elif country == 5: + return "Germany", Germany_Hotels + else: + print("Invalid country\n") + except ValueError: + print("Invalid input\n") + +def login(): + try: + user = input("Username: ") + if user == USERDATA['username']: + passw = input("Password: ") + if passw == USERDATA['password']: + return user, passw + else: + print("Invalid password") + else: + print("Invalid username") + return None, None + except: + print("Invalid input") + +if __name__ == "__main__": + main() \ No newline at end of file From 95f6d0afb5ab5b23adb06333085a2d3c276ce401 Mon Sep 17 00:00:00 2001 From: Daniel Tamayo Date: Mon, 15 Jan 2024 17:22:28 -0500 Subject: [PATCH 6/7] Fifth challenge completed and minor changes on fourth challenge --- ElyRiven/04_RHHotels.py | 4 +- ElyRiven/05_AirlineSystem.py | 167 +++++++++++++++++++++++++++++++++++ 2 files changed, 169 insertions(+), 2 deletions(-) create mode 100644 ElyRiven/05_AirlineSystem.py diff --git a/ElyRiven/04_RHHotels.py b/ElyRiven/04_RHHotels.py index 784fff0..66e3682 100644 --- a/ElyRiven/04_RHHotels.py +++ b/ElyRiven/04_RHHotels.py @@ -10,8 +10,8 @@ # print the total cost, and if the user agrees, print a confirmation message for the reservation. If not, return to the main menu. USERDATA = { - 'username': 'e', - 'password': 'e' + 'username': 'elyriven', + 'password': 'pass123' } Spain_Hotels = [ diff --git a/ElyRiven/05_AirlineSystem.py b/ElyRiven/05_AirlineSystem.py new file mode 100644 index 0000000..3e44631 --- /dev/null +++ b/ElyRiven/05_AirlineSystem.py @@ -0,0 +1,167 @@ +# 5. Turkish Airlines has just launched an offer to travel among the following destinations: Turkey, Greece, Lebanon, Spain, and Portugal. Develop an algorithm with the following characteristics: + +# It must have a login and validate the data; after the third failed attempt, it should be locked. +# The user must choose the origin country and the destination country, the flight date, and the condition: Economy or First Class. +# The user must choose if they want to check an additional piece of luggage into the hold. +# Hand luggage is free of charge. +# The user must purchase both the outbound and return tickets. +# The user can choose their preferred meal: Regular, Vegetarian, Kosher. +# The program must collect the following data: Name, country of origin, passport, and destination country. +# Upon completing the process, the system will display everything the user has previously chosen along with their information. +# The system will provide the option to confirm the reservation or cancel it. If the user chooses YES, a confirmation message will appear. If not, it will return to the main menu. + +from datetime import datetime + +USERDATA = { + 'username': 'e', + 'password': 'e' +} + +DESTINATIONS = ['turkey', 'greece', 'lebanon', 'spain', 'portugal'] +CONDITIONS = ['economy', 'first class'] +MEALS = ['regular', 'vegetarian', 'kosher'] + +def main(): + print("Welcome to Turkish Airlines\n") + login() + while True: + originCountry = getOriginCountry() + destinationCountry = getDestinationCountry(originCountry) + date = getDate() + condition = getCondition() + additionalLuggage = getAdditionalLuggage() + meal = getMeal() + userData = getUserData(originCountry, destinationCountry) + print("\nFlight Summary\n") + print(f"User Data:\nName: {userData[0]} \nPassport: {userData[1]}\n") + print(f"Origin Country: {originCountry.title()}\nDestination Country: {destinationCountry.title()}\nDate: {date}\nCondition: {condition.title()}\nAdditional Luggage: {additionalLuggage}\nMeal: {meal.title()}\n") + if getConfirmation(): + print("Reservation confirmed\n") + else: + print("Reservation cancelled\n") + +# Confirm flight +def getConfirmation(): + while True: + confirmation = input("Confirm flight? (Y/N): ").lower() + if confirmation == 'y': + return True + elif confirmation == 'n': + return False + else: + print("Invalid input\n") + +# Get user data +def getUserData(origin, destination): + name = input("Name: ") + passport = input("Passport: ") + print(f"Origin Country: {origin.title()}") + print(f"Destination Country: {destination.title()}") + return [name,passport] + +# Get meal preference +def getMeal(): + while True: + print("Available Meals \n") + for i,meal in enumerate(MEALS): + print(f"{i+1}. {meal.title()}") + try: + meal = int(input(">> ")) -1 + if 0 <= meal < len(MEALS): + return MEALS[meal] + else: + print("Invalid meal\n") + except ValueError: + print("Invalid input\n") + +# Ask if user wants to check additional luggage +def getAdditionalLuggage(): + while True: + additionalLuggage = input("Do you want to check additional luggage? (Y/N): ").lower() + if additionalLuggage == 'y': + return "Yes" + elif additionalLuggage == 'n': + return "No" + else: + print("Invalid input\n") + +# Get condition of flight +def getCondition(): + while True: + print("Available Conditions \n") + for i,condition in enumerate(CONDITIONS): + print(f"{i+1}. {condition.title()}") + try: + condition = int(input(">> ")) -1 + if 0 <= condition < len(CONDITIONS): + return CONDITIONS[condition] + else: + print("Invalid condition\n") + except ValueError: + print("Invalid input\n") + +# Get date of flight +def getDate(): + while True: + date = input("Date of flight (DD/MM/YYYY): ") + try: + datetime.strptime(date, '%d/%m/%Y') + return date + except ValueError: + print("Invalid input\n") + +# Show available destinations based on origin country +def getDestinationCountry(origin): + while True: + print("Available Final Destinations \n") + for i,country in enumerate(DESTINATIONS): + if country != origin: + print(f"{i+1}. {country.title()}") + try: + destinationCountry = int(input(">> ")) -1 + if 0 <= destinationCountry < len(DESTINATIONS) and DESTINATIONS[destinationCountry] != origin: + return DESTINATIONS[destinationCountry] + else: + print("Invalid country\n") + except: + print("Invalid input\n") + +# Show available origin countries +def getOriginCountry(): + while True: + print("Available Origin Destinations \n") + for i,country in enumerate(DESTINATIONS): + print(f"{i+1}. {country.title()}") + try: + originCountry = int(input(">> ")) -1 + if 0 <= originCountry < len(DESTINATIONS): + return DESTINATIONS[originCountry] + else: + print("Invalid country\n") + except ValueError: + print("Invalid input\n") + +def login(): + attempts = 3 + print("Please login to continue\n") + while attempts > 0: + try: + user = input("Username: ") + if user == USERDATA['username']: + passw = input("Password: ") + if passw == USERDATA['password']: + return True + else: + print("Invalid password") + else: + print("Invalid username") + attempts -= 1 + print(f"Attempts left: {attempts}\n") + except: + print("Invalid input") + else: + print("Too many failed attempts. Please try again later") + return False + +if __name__ == "__main__": + main() \ No newline at end of file From 61519a1cb6b38b404c010309b227ddc8a795b983 Mon Sep 17 00:00:00 2001 From: Daniel Tamayo Date: Mon, 15 Jan 2024 17:23:19 -0500 Subject: [PATCH 7/7] Minor changes on fifth challenge --- ElyRiven/05_AirlineSystem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ElyRiven/05_AirlineSystem.py b/ElyRiven/05_AirlineSystem.py index 3e44631..e825062 100644 --- a/ElyRiven/05_AirlineSystem.py +++ b/ElyRiven/05_AirlineSystem.py @@ -13,8 +13,8 @@ from datetime import datetime USERDATA = { - 'username': 'e', - 'password': 'e' + 'username': 'elizabeth', + 'password': 'pass123' } DESTINATIONS = ['turkey', 'greece', 'lebanon', 'spain', 'portugal']