From 26bb39da1ee8951df0bda9dfa040655bd5c5d51c Mon Sep 17 00:00:00 2001 From: Jaime Pastrian Date: Sat, 20 Jan 2024 01:49:20 -0300 Subject: [PATCH 01/12] [INITIAL] Print menu and data object --- .vscode/settings.json | 7 ++++ 01_manchester_united.py | 78 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 01_manchester_united.py diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3155f0f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "workbench.colorCustomizations": { + "activityBar.background": "#2F2F17", + "titleBar.activeBackground": "#424120", + "titleBar.activeForeground": "#FBFBF6" + } +} \ No newline at end of file diff --git a/01_manchester_united.py b/01_manchester_united.py new file mode 100644 index 0000000..64d029a --- /dev/null +++ b/01_manchester_united.py @@ -0,0 +1,78 @@ +import os +import sys + +manchester_players = [ + { + "jersey": 8, + "name": "Bruno Fernandes", + "goals": 5, + "points_in_speed": 6, + "points_in_assists": 9, + "points_in_passing": 10, + "defensive_involvements": 3 + }, + { + "jersey": 11, + "name": "Rasmus Hojlund", + "goals": 12, + "points_in_speed": 8, + "points_in_assists": 2, + "points_in_passing": 6, + "defensive_involvements": 2 + }, + { + "jersey": 5, + "name": "Harry Maguire", + "goals": 1, + "points_in_speed": 5, + "points_in_assists": 1, + "points_in_passing": 7, + "defensive_involvements": 9 + }, + { + "jersey": 17, + "name": "Alejandro Garnacho", + "goals": 8, + "points_in_speed": 7, + "points_in_assists": 8, + "points_in_passing": 6, + "defensive_involvements": 0 + }, + { + "jersey": 7, + "name": "Mason Mount", + "goals": 2, + "points_in_speed": 6, + "points_in_assists": 4, + "points_in_passing": 8, + "defensive_involvements": 1 + }, + ] +#print(manchester_players[0]["name"]) + +login_attempts = 0 + +def print_menu(): + os.system('clear') + print("WELCOME TO MANCHESTER UNITED SYSTEM") + print("===================================") + print("1. Player Review") + print("2. Compare two players") + print("3. Fastest player") + print("4. Top goal scorer") + print("5. Player with the most assists") + print("6. Player with highest passing accuracy") + print("7. Player with the most defensive involvements") + print("8. Exit") + +def show_player_review(jersey): + print() + +while option != 8: + print_menu() + + option = int(input("Choose an option: ")) + if option == 1: + player_number = int(input("Jersey player number:")) + show_player_review(player_number) + input("Press ENTER to continue") From 3118ac8604e6e9e392d66a4d48a6cb658e825c95 Mon Sep 17 00:00:00 2001 From: Jaime Pastrian Date: Sat, 20 Jan 2024 02:05:03 -0300 Subject: [PATCH 02/12] [ADD] name functions and menu logic --- 01_manchester_united.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/01_manchester_united.py b/01_manchester_united.py index 64d029a..e3d5dd6 100644 --- a/01_manchester_united.py +++ b/01_manchester_united.py @@ -68,6 +68,24 @@ def print_menu(): def show_player_review(jersey): print() +def compare_two_players(player1, player2): + print() + +def find_fastest_player(): + print() + +def find_top_goal_scorer(): + print() + +def find_player_with_most_assists() + print() + +def find_player_highest_passing_accuracy(): + print() + +def find_player_most_defensive_involvements(): + print() + while option != 8: print_menu() @@ -76,3 +94,25 @@ def show_player_review(jersey): player_number = int(input("Jersey player number:")) show_player_review(player_number) input("Press ENTER to continue") + elif option == 2: + player1 = int(input("First jersey player number:")) + player2 = int(input("Second jersey player number:")) + compare_two_players(player1, player2) + input("Press ENTER to continue") + elif option == 3: + find_fastest_player() + input("Press ENTER to continue") + elif option == 4: + find_top_goal_scorer() + input("Press ENTER to continue") + elif option == 5: + find_player_with_most_assists() + input("Press ENTER to continue") + elif option == 6: + find_player_highest_passing_accuracy() + input("Press ENTER to continue") + elif option == 7: + find_player_most_defensive_involvements() + input("Press ENTER to continue") + +print("Glory glory Man United!! See your soon!") From 2d8ef72bf064b4bd6492f295a3c5b7de1e49ba17 Mon Sep 17 00:00:00 2001 From: Jaime Pastrian Date: Sat, 20 Jan 2024 16:07:01 -0300 Subject: [PATCH 03/12] [ADD] player review and compare two players --- 01_manchester_united.py | 88 +++++++++++++++++++++++++++++++++-------- 1 file changed, 72 insertions(+), 16 deletions(-) diff --git a/01_manchester_united.py b/01_manchester_united.py index e3d5dd6..52e4372 100644 --- a/01_manchester_united.py +++ b/01_manchester_united.py @@ -1,8 +1,8 @@ import os import sys -manchester_players = [ - { +manchester_players = { + 'jersey_8': { "jersey": 8, "name": "Bruno Fernandes", "goals": 5, @@ -11,7 +11,7 @@ "points_in_passing": 10, "defensive_involvements": 3 }, - { + 'jersey_11': { "jersey": 11, "name": "Rasmus Hojlund", "goals": 12, @@ -20,7 +20,7 @@ "points_in_passing": 6, "defensive_involvements": 2 }, - { + 'jersey_5': { "jersey": 5, "name": "Harry Maguire", "goals": 1, @@ -29,7 +29,7 @@ "points_in_passing": 7, "defensive_involvements": 9 }, - { + 'jersey_17': { "jersey": 17, "name": "Alejandro Garnacho", "goals": 8, @@ -38,7 +38,7 @@ "points_in_passing": 6, "defensive_involvements": 0 }, - { + 'jersey_7': { "jersey": 7, "name": "Mason Mount", "goals": 2, @@ -47,10 +47,11 @@ "points_in_passing": 8, "defensive_involvements": 1 }, - ] +} #print(manchester_players[0]["name"]) login_attempts = 0 +option = 0 def print_menu(): os.system('clear') @@ -66,18 +67,65 @@ def print_menu(): print("8. Exit") def show_player_review(jersey): - print() + for key, player in manchester_players.items(): + if str(player["jersey"]) == jersey: + print("") + print("Player:", player["name"]) + print("Jersey:", player["jersey"]) + print("Goals:", player["goals"]) + print("Points in speed:", player["points_in_speed"]) + print("Points in assists:", player["points_in_assists"]) + print("Points in passing accuracy:", player["points_in_passing"]) + print("Defensive involvements:", player["defensive_involvements"]) + print("") + return True + return False def compare_two_players(player1, player2): - print() + players_count = 0 + out_print = "" + for key, player in manchester_players.items(): + if str(player["jersey"]) == player1: + out_print += "\n" + out_print += "PLAYER 1\n" + out_print += "--------\n" + out_print += "\n" + out_print += "Player: " + player["name"] + "\n" + out_print += "Jersey: " + str(player["jersey"]) + "\n" + out_print += "Goals:" + str(player["goals"]) + "\n" + out_print += "Points in speed:" + str(player["points_in_speed"]) + "\n" + out_print += "Points in assists:" + str(player["points_in_assists"]) + "\n" + out_print += "Points in passing accuracy:" + str(player["points_in_passing"]) + "\n" + out_print += "Defensive involvements:" + str(player["defensive_involvements"]) + "\n" + out_print += "\n" + players_count += 1 + elif str(player["jersey"]) == player2: + out_print += "\n" + out_print += "PLAYER 2\n" + out_print += "--------\n" + out_print += "\n" + out_print += "Player: " + player["name"] + "\n" + out_print += "Jersey: " + str(player["jersey"]) + "\n" + out_print += "Goals:" + str(player["goals"]) + "\n" + out_print += "Points in speed:" + str(player["points_in_speed"]) + "\n" + out_print += "Points in assists:" + str(player["points_in_assists"]) + "\n" + out_print += "Points in passing accuracy:" + str(player["points_in_passing"]) + "\n" + out_print += "Defensive involvements:" + str(player["defensive_involvements"]) + "\n" + out_print += "\n" + players_count += 1 + if players_count == 2: + print(out_print) + return True + return False def find_fastest_player(): - print() + for key, player in manchester_players.items(): + print(player["name"]) def find_top_goal_scorer(): print() -def find_player_with_most_assists() +def find_player_with_most_assists(): print() def find_player_highest_passing_accuracy(): @@ -91,13 +139,21 @@ def find_player_most_defensive_involvements(): option = int(input("Choose an option: ")) if option == 1: - player_number = int(input("Jersey player number:")) - show_player_review(player_number) + player_number = input("Write a Jersey player number: ") + result = show_player_review(player_number) + if result == False: + print("I couldn't find jersey number", player_number) + print("Please try again.") + print("") input("Press ENTER to continue") elif option == 2: - player1 = int(input("First jersey player number:")) - player2 = int(input("Second jersey player number:")) - compare_two_players(player1, player2) + player1 = input("First jersey player number to compare: ") + player2 = input("Second jersey player number to compare: ") + result = compare_two_players(player1, player2) + if result == False: + print("\nI couldn't find a jersey number") + print("Please try again.") + print("") input("Press ENTER to continue") elif option == 3: find_fastest_player() From 3c376feea587b11abfed1e7dbe2d0b3e2ddd3948 Mon Sep 17 00:00:00 2001 From: Jaime Pastrian Date: Sat, 20 Jan 2024 16:20:42 -0300 Subject: [PATCH 04/12] [ADD] Fastest player --- 01_manchester_united.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/01_manchester_united.py b/01_manchester_united.py index 52e4372..1d3ed66 100644 --- a/01_manchester_united.py +++ b/01_manchester_united.py @@ -114,13 +114,24 @@ def compare_two_players(player1, player2): out_print += "\n" players_count += 1 if players_count == 2: + #TODO: show result in a comparation table print(out_print) return True return False def find_fastest_player(): + fastest_name = "" + points_in_speed = 0 for key, player in manchester_players.items(): - print(player["name"]) + if points_in_speed < player["points_in_speed"]: + fastest_name = player["name"] + points_in_speed = player["points_in_speed"] + if points_in_speed > 0: + print("Fastest player:", fastest_name) + print("Points in speed:", points_in_speed) + print("") + return True + return False def find_top_goal_scorer(): print() @@ -156,7 +167,10 @@ def find_player_most_defensive_involvements(): print("") input("Press ENTER to continue") elif option == 3: - find_fastest_player() + result = find_fastest_player() + if result == False: + print("\nUnknown error. Please try again.") + print("") input("Press ENTER to continue") elif option == 4: find_top_goal_scorer() From 9cd7147f0daa76a4daf539bf9496e3702ea845e4 Mon Sep 17 00:00:00 2001 From: Jaime Pastrian Date: Sat, 20 Jan 2024 16:25:39 -0300 Subject: [PATCH 05/12] [ADD] top scorer option --- 01_manchester_united.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/01_manchester_united.py b/01_manchester_united.py index 1d3ed66..6478794 100644 --- a/01_manchester_united.py +++ b/01_manchester_united.py @@ -134,7 +134,18 @@ def find_fastest_player(): return False def find_top_goal_scorer(): - print() + top_scorer_name = "" + more_goals = 0 + for key, player in manchester_players.items(): + if more_goals < player["goals"]: + top_scorer_name = player["name"] + more_goals = player["goals"] + if more_goals > 0: + print("Top scorer player:", top_scorer_name) + print("Goals:", more_goals) + print("") + return True + return False def find_player_with_most_assists(): print() @@ -173,7 +184,10 @@ def find_player_most_defensive_involvements(): print("") input("Press ENTER to continue") elif option == 4: - find_top_goal_scorer() + result = find_top_goal_scorer() + if result == False: + print("\nUnknown error. Please try again.") + print("") input("Press ENTER to continue") elif option == 5: find_player_with_most_assists() From a193eb60c373fc5b121292bfdf843b31afd0c6a7 Mon Sep 17 00:00:00 2001 From: Jaime Pastrian Date: Sat, 20 Jan 2024 16:31:38 -0300 Subject: [PATCH 06/12] [ADD] player with the most assists --- 01_manchester_united.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/01_manchester_united.py b/01_manchester_united.py index 6478794..78b92f2 100644 --- a/01_manchester_united.py +++ b/01_manchester_united.py @@ -148,7 +148,18 @@ def find_top_goal_scorer(): return False def find_player_with_most_assists(): - print() + more_assist_name = "" + more_assists = 0 + for key, player in manchester_players.items(): + if more_assists < player["points_in_assists"]: + more_assist_name = player["name"] + more_assists = player["points_in_assists"] + if more_assists > 0: + print("Player with the most assists:", more_assist_name) + print("Points in assists:", more_assists) + print("") + return True + return False def find_player_highest_passing_accuracy(): print() From 2a63a0288f87007eb93f9c0957938887a82da356 Mon Sep 17 00:00:00 2001 From: Jaime Pastrian Date: Sat, 20 Jan 2024 16:37:36 -0300 Subject: [PATCH 07/12] [ADD] highest passing accuracy --- 01_manchester_united.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/01_manchester_united.py b/01_manchester_united.py index 78b92f2..bdc9f2c 100644 --- a/01_manchester_united.py +++ b/01_manchester_united.py @@ -162,7 +162,18 @@ def find_player_with_most_assists(): return False def find_player_highest_passing_accuracy(): - print() + accuracy_name = "" + accuracy = 0 + for key, player in manchester_players.items(): + if accuracy < player["points_in_passing"]: + accuracy_name = player["name"] + accuracy = player["points_in_passing"] + if accuracy > 0: + print("Player with the most accuracy:", accuracy_name) + print("Points in assists:", accuracy) + print("") + return True + return False def find_player_most_defensive_involvements(): print() @@ -201,10 +212,16 @@ def find_player_most_defensive_involvements(): print("") input("Press ENTER to continue") elif option == 5: - find_player_with_most_assists() + result = find_player_with_most_assists() + if result == False: + print("\nUnknown error. Please try again.") + print("") input("Press ENTER to continue") elif option == 6: - find_player_highest_passing_accuracy() + result = find_player_highest_passing_accuracy() + if result == False: + print("\nUnknown error. Please try again.") + print("") input("Press ENTER to continue") elif option == 7: find_player_most_defensive_involvements() From 9633e3ad54e18220caaf0ac50ea5f8c3d5069c8f Mon Sep 17 00:00:00 2001 From: Jaime Pastrian Date: Sat, 20 Jan 2024 16:43:00 -0300 Subject: [PATCH 08/12] [ADD] defensive involvements --- 01_manchester_united.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/01_manchester_united.py b/01_manchester_united.py index bdc9f2c..8b961f3 100644 --- a/01_manchester_united.py +++ b/01_manchester_united.py @@ -176,7 +176,18 @@ def find_player_highest_passing_accuracy(): return False def find_player_most_defensive_involvements(): - print() + defense_name = "" + involvements = 0 + for key, player in manchester_players.items(): + if involvements < player["defensive_involvements"]: + defense_name = player["name"] + involvements = player["defensive_involvements"] + if involvements > 0: + print("\nPlayer with the most defensive involvements:", defense_name) + print("Defensive involvements:", involvements) + print("") + return True + return False while option != 8: print_menu() @@ -224,7 +235,10 @@ def find_player_most_defensive_involvements(): print("") input("Press ENTER to continue") elif option == 7: - find_player_most_defensive_involvements() + result = find_player_most_defensive_involvements() + if result == False: + print("\nUnknown error. Please try again.") + print("") input("Press ENTER to continue") print("Glory glory Man United!! See your soon!") From a7d17aee169387ffc9482d939e538ea13dc29c13 Mon Sep 17 00:00:00 2001 From: Jaime Pastrian Date: Sun, 21 Jan 2024 01:16:47 -0300 Subject: [PATCH 09/12] [ADD] exercise 5 turkish airlines complete --- 05_turkish_airlines.py | 116 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 05_turkish_airlines.py diff --git a/05_turkish_airlines.py b/05_turkish_airlines.py new file mode 100644 index 0000000..481925c --- /dev/null +++ b/05_turkish_airlines.py @@ -0,0 +1,116 @@ +import os +import sys + +countries = ["Turkey", "Greece", "Lebanon", "Spain", "Portugal"] +login_attempts = 0 +username = "mitnick" +password = "god" +login_success = False +flight_round_trip_price = 1000 +luggage_price = 50 +first_class_multi = 2.2 +total_price = 0 +option = 0 + +def print_menu(): + os.system('clear') + print("WELCOME TO TURKISH AIRLINES") + print("===========================") + print("1. Create a reservation") + print("2. Exit") + +def print_countries(): + count = 1 + for country in countries: + print(count, "-", country) + count += 1 + +def print_class(): + print("\n1. Economy") + print("2. First Class") + +def print_meals(): + print("\n1. Regular") + print("2. Vegetarian") + print("3. Kosher") + +os.system('clear') +print("WELCOME TO TURKISH AIRLINES") +print("===========================") +while login_attempts !=3: + user_login = input("Username: ") + pass_login = input("Password: ") + if username == user_login and password == pass_login: + login_success = True + break + else: + login_attempts += 1 + if login_attempts == 3: + print("Better luck next time! Bye.") + sys.exit() + print("Sorry, try again.") + +while option != 2: + print_menu() + option = int(input("Choose an option: ")) + if option == 1: + print_countries() + origin = int(input("Choose origin country: ")) + print_countries() + destination = int(input("Choose a destination: ")) + date = input("Date you want to travel: ") + print_class() + flight_class = input("Which class do you want to travel? ") + luggage = input("Do you want to check an additional luggage? (y/n) ") + print_meals() + meal = input("What would you like to eat in your flight? ") + print("\nNow we need some information about you...") + name = input("Name: ") + nationality = input("Nationality: ") + passport = input("Passport number: ") + + #Show everything to confirm the purchase + print("\nPurchase details") + print("----------------") + + print("Country of origin:", countries[origin - 1]) + print("Destination:", countries[destination - 1]) + print("Trip date:", date) + + if int(flight_class) == 2: + print("Class: First class") + total_price = flight_round_trip_price * first_class_multi + else: + print("Class: Economy class") + total_price = flight_round_trip_price + + if int(meal) == 2: + print("Meal: Vetetarian") + elif int(meal) == 3: + print("Meal: Kosher") + else: + print("Meal: Regular") + + if luggage == "y" or luggage == "Y": + print("Luggage: Yes") + total_price += luggage_price + + print("\nTotal price:", total_price, "USD") + print("Name:", name) + print("Nationality:", nationality) + print("Passport number:", passport) + + print("\nIs this information OK?") + verify = input("Do you confirm this reservation? (y/n)") + if verify == "y" or verify == "Y": + print("\nThank you for using Turkish Airlines. Your reservation is complete.") + print("Goodbye!") + sys.exit() + else: + print("\nYour reservation will not be saved.") + input("Press ENTER to continue") + + + + + From 1bd389b8417e870afcc52ef55e5c20fadf2f9e71 Mon Sep 17 00:00:00 2001 From: Jaime Pastrian Date: Sun, 21 Jan 2024 01:33:14 -0300 Subject: [PATCH 10/12] [ADD] level_1 markdown --- level_1.md | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 level_1.md diff --git a/level_1.md b/level_1.md new file mode 100644 index 0000000..5df38d3 --- /dev/null +++ b/level_1.md @@ -0,0 +1,78 @@ +Author: @blindma1den + +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. +-------------------------------------------------------------------------------------- + +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. + +__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 +-------------------------------------------------------------------------------------- + +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. +-------------------------------------------------------------------------------------- + +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. +-------------------------------------------------------------------------------------- + +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. + + + +Enjoy! + +@blindma1den \ No newline at end of file From 534bd02d606438832189aceb0a74fdc1e3104139 Mon Sep 17 00:00:00 2001 From: Jaime Pastrian Date: Sun, 21 Jan 2024 02:31:17 -0300 Subject: [PATCH 11/12] [ADD] Exercise 03 Valencia hospital.. in progress --- 03_valencia_hospital.py | 69 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 03_valencia_hospital.py diff --git a/03_valencia_hospital.py b/03_valencia_hospital.py new file mode 100644 index 0000000..4ac145b --- /dev/null +++ b/03_valencia_hospital.py @@ -0,0 +1,69 @@ +import os +import sys + +specialties = [ + "General medicine", + "Emergency Care", + "Clinical Analysis", + "Cardiology", + "Neurology", + "Nutrition", + "Physiotherapy", + "Traumatology", + "Internal Medicine" +] + +doctors = { + "General medicine": {"doctors": ["Doctor House", "Meredith Grey","Derek Shepherd"]}, + "Emergency Care": {"doctors": ["Alex Karev", "Lexie Grey", "Izzie Stevens"]}, + "Clinical Analysis": {"doctors": ["Andrew DeLuca", "Mark Sloan", "Miranda Bailey"]}, + "Cardiology": {"doctors": ["Cristina Yang", "Owen Hunt", "Maggie Pierce"]}, + "Neurology": {"doctors": ["Amelia Sheperd", "April Kepner", "Jackson Avery"]}, + "Nutrition": {"doctors": ["Richard Webber", "Ellis Grey", "Addison Montgomery"]}, + "Physiotherapy": {"doctors": ["George O'Malley", "Finn Dandridge", "Eric Foreman"]}, + "Traumatology": {"doctors": ["Allison Cameron", "Robert Chase", "Remy Hadley"]}, + "Internal Medicine": {"doctors": ["Chris Taub", "Philip Weber", "Dana Miller"]} +} + +login_attempts = 0 +username = "mitnick" +password = "god" +option = 0 + +def print_menu(): + os.system('clear') + print("WELCOME TO VALENCIA HOSPITAL") + print("============================") + print("1. Schedule an appointment") + print("2. Exit") + +def print_specialties(): + count = 1 + for specialty in specialties: + print(count, "-", specialty) + count += 1 + +os.system('clear') +print("WELCOME TO VALENCIA HOSPITAL") +print("============================") +while login_attempts !=3: + user_login = input("Username: ") + pass_login = input("Password: ") + if username == user_login and password == pass_login: + login_success = True + break + else: + login_attempts += 1 + if login_attempts == 3: + print("Better luck next time! Bye.") + sys.exit() + print("Sorry, try again.") + +while option != 2: + print_menu() + option = int(input("Choose an option: ")) + if option == 1: + print_specialties() + option_specialty = int(input("Choose a specialty:")) + print(doctors[specialties[option_specialty - 1]]) + input("Press ENTER to continue") \ No newline at end of file From f5454c64b664cb7388627c2e5ae3e6c8161ed37e Mon Sep 17 00:00:00 2001 From: "Jaime P." Date: Mon, 5 Feb 2024 03:04:28 -0300 Subject: [PATCH 12/12] [UPDATE] Valencia Hospital solution OK --- 03_valencia_hospital.py | 52 ++++++++++++++++++++++++++++++++++++++--- level_1.md | 49 +++++++++++++++++++------------------- 2 files changed, 74 insertions(+), 27 deletions(-) diff --git a/03_valencia_hospital.py b/03_valencia_hospital.py index 4ac145b..7fca0ba 100644 --- a/03_valencia_hospital.py +++ b/03_valencia_hospital.py @@ -25,6 +25,10 @@ "Internal Medicine": {"doctors": ["Chris Taub", "Philip Weber", "Dana Miller"]} } +users = [] + +appointments = [] + login_attempts = 0 username = "mitnick" password = "god" @@ -43,6 +47,32 @@ def print_specialties(): print(count, "-", specialty) count += 1 +def verify_appointment(name, doctor, specialty): + if len(appointments) == 0: + return [True,""] + count_name = 0 + count_doctor = 0 + count_specialty = 0 + for appointment in appointments: + if appointment[0] == name: + count_name += 1 + if appointment[0] == name and appointment[1] == doctor: + count_doctor += 1 + if appointment[0] == name and appointment[2] == specialty: + count_specialty += 1 + # print("Counts:", count_name, count_doctor, count_specialty) + + if count_doctor >= 1: + return [False, "You already have an appointment with " + doctor] + + if count_specialty >= 1: + return [False, "You already have an appointment in the specialty " + specialty] + + if count_name > 2: + return [False, "You already have 3 appointments. Sorry"] + else: + return [True,""] + os.system('clear') print("WELCOME TO VALENCIA HOSPITAL") print("============================") @@ -64,6 +94,22 @@ def print_specialties(): option = int(input("Choose an option: ")) if option == 1: print_specialties() - option_specialty = int(input("Choose a specialty:")) - print(doctors[specialties[option_specialty - 1]]) - input("Press ENTER to continue") \ No newline at end of file + option_specialty = int(input("Choose a specialty: ")) + print("") + user_name = input("What's your name? ") + print("") + i = 1 + for doctor in doctors[specialties[option_specialty - 1]]["doctors"]: + print(str(i) + "- " + doctor) + i += 1 + + doctor_option = int(input("Choose a doctor: ")) + select_doctor = doctors[specialties[option_specialty - 1]]["doctors"][doctor_option - 1] + result = [True, ""] + result = verify_appointment(user_name, select_doctor, specialties[option_specialty - 1]) + if result[0] == True: + appointments.append([user_name, select_doctor, specialties[option_specialty - 1]]) + print("Your appointment is saved.") + else: + print("\nThere is an error with your appointment. " + result[1]) + input("\nPress ENTER to continue") \ No newline at end of file diff --git a/level_1.md b/level_1.md index 5df38d3..3027a81 100644 --- a/level_1.md +++ b/level_1.md @@ -1,26 +1,28 @@ Author: @blindma1den -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. +# 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. +* 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. --------------------------------------------------------------------------------------- +1. Player Review: By entering the player's jersey number, they can access the player's characteristics. +2. Compare two players: The system prompts for two jersey numbers and displays the data of both players on screen. +3. Identify the fastest player: Displays the player with the most points in speed. +4. Identify the top goal scorer: Displays the player with the most points in goals. +5. Identify the player with the most assists: Displays the player with the most points in assists. +6. Identify the player with the highest passing accuracy: Displays the player with the most points in passing accuracy. +7. Identify the player with the most defensive involvements: Displays the player with the most points in defensive involvements. +8. The system should also allow returning to the main menu. -2. A travel agency has a special offer for traveling in any season of 2024. Their destinations are: +# 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. @@ -32,10 +34,10 @@ Design a system that helps users choose their best destination according to thei __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 --------------------------------------------------------------------------------------- +__Clue: You could consider the user's budget__ -3. The Valencia Hospital is developing an application to manage appointments. Design an algorithm for this application with the following features: +# 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. @@ -46,9 +48,9 @@ Upon selecting a specialty, it will display if the user prefers a morning or aft Display available specialists. The user can choose their preferred specialist. The basic process is: Login -> Choose specialty -> Choose doctor -> Choose time slot. --------------------------------------------------------------------------------------- -4. The RH Hotels chain has hired you to design the booking algorithm for their mobile application: +# 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. @@ -58,9 +60,9 @@ The user can make reservations at any time of the year and at any hour, and book 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. --------------------------------------------------------------------------------------- -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: +# 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. @@ -72,7 +74,6 @@ Upon completing the process, the system will display everything the user has pre 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. - Enjoy! @blindma1den \ No newline at end of file