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..8b961f3 --- /dev/null +++ b/01_manchester_united.py @@ -0,0 +1,244 @@ +import os +import sys + +manchester_players = { + 'jersey_8': { + "jersey": 8, + "name": "Bruno Fernandes", + "goals": 5, + "points_in_speed": 6, + "points_in_assists": 9, + "points_in_passing": 10, + "defensive_involvements": 3 + }, + 'jersey_11': { + "jersey": 11, + "name": "Rasmus Hojlund", + "goals": 12, + "points_in_speed": 8, + "points_in_assists": 2, + "points_in_passing": 6, + "defensive_involvements": 2 + }, + 'jersey_5': { + "jersey": 5, + "name": "Harry Maguire", + "goals": 1, + "points_in_speed": 5, + "points_in_assists": 1, + "points_in_passing": 7, + "defensive_involvements": 9 + }, + 'jersey_17': { + "jersey": 17, + "name": "Alejandro Garnacho", + "goals": 8, + "points_in_speed": 7, + "points_in_assists": 8, + "points_in_passing": 6, + "defensive_involvements": 0 + }, + 'jersey_7': { + "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 +option = 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): + 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): + 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: + #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(): + 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(): + 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(): + 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(): + 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(): + 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() + + option = int(input("Choose an option: ")) + if option == 1: + 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 = 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: + result = find_fastest_player() + if result == False: + print("\nUnknown error. Please try again.") + print("") + input("Press ENTER to continue") + elif option == 4: + result = find_top_goal_scorer() + if result == False: + print("\nUnknown error. Please try again.") + print("") + input("Press ENTER to continue") + elif option == 5: + result = find_player_with_most_assists() + if result == False: + print("\nUnknown error. Please try again.") + print("") + input("Press ENTER to continue") + elif option == 6: + result = find_player_highest_passing_accuracy() + if result == False: + print("\nUnknown error. Please try again.") + print("") + input("Press ENTER to continue") + elif option == 7: + 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!") diff --git a/03_valencia_hospital.py b/03_valencia_hospital.py new file mode 100644 index 0000000..7fca0ba --- /dev/null +++ b/03_valencia_hospital.py @@ -0,0 +1,115 @@ +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"]} +} + +users = [] + +appointments = [] + +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 + +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("============================") +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("") + 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/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") + + + + + diff --git a/level_1.md b/level_1.md new file mode 100644 index 0000000..3027a81 --- /dev/null +++ b/level_1.md @@ -0,0 +1,79 @@ +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: + +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: + +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