diff --git a/__pycache__/login.cpython-312.pyc b/__pycache__/login.cpython-312.pyc new file mode 100644 index 0000000..b2af80c Binary files /dev/null and b/__pycache__/login.cpython-312.pyc differ diff --git a/__pycache__/manchester.cpython-312.pyc b/__pycache__/manchester.cpython-312.pyc new file mode 100644 index 0000000..93cbf8f Binary files /dev/null and b/__pycache__/manchester.cpython-312.pyc differ diff --git a/hospital.py b/hospital.py new file mode 100644 index 0000000..742ede1 --- /dev/null +++ b/hospital.py @@ -0,0 +1,33 @@ +'''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.''' + +class User: + username:str + password:str + limit:int + +class Appointment: + generalMedicine:str + emergencyCare:str + clinicalAnalysis:str + cardiology:str + neurology:str + nutrition:str + physiotherapy:str + traumatology:str + internalMedicine:str + +def login(username, password): + for i in range(3): + if username and password: + return True + else:False diff --git a/hotels.py b/hotels.py new file mode 100644 index 0000000..0101522 --- /dev/null +++ b/hotels.py @@ -0,0 +1,72 @@ +'''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.''' +from login import login, users + +class Hotel: + class Room: + room_type:str + price:int + available:int + def __init__(self, room_type, price, available) -> None: + self.room_type=room_type + self.price=price + self.available=available + def __str__(self) -> str: + return f"room type: {self.room_type}, price: {self.price}, available: {self.available}" + rooms = [Room("single", 100, 3), Room("double", 200, 6), Room("group", 350, 6), Room("vip", 450, 6), Room("luxury", 550, 3)] + + def __init__(self, country, city) -> None: + self.country=country + self.city=city + self.rooms + + def __str__(self) -> str: + return f"country: {self.country}, city: {self.city}, rooms: {[str(room) for room in self.rooms]}" + def reservation(self, country, city ): + pass + +hotels =[Hotel("Spain", "Madrid"),Hotel("Spain", "Barcelona"), Hotel("Spain", "Valencia"),] + + +def search_room(country:str, city:str)->Hotel | bool: + ''' + hace una búsqueda del usuario en las credenciales almacenadas si el usuario existe. + + :param: country:str - ID proporcionado por el usuario. + :return: object or error - objeto resultante contiene datos del usuario. + + ''' + try: + hotel= filter(lambda hotel: hotel.country== country and hotel.city ==city, hotels) + return list(hotel)[0] + except: + return False + +def isvalid(country:str, city:str)->bool: + ''' + valida que las credenciales pertenezcan al usuario. + + :param: country, password: str - ID y Password proporcionados por el usuario. + :return: bool - son correctas ambas credenciales? + ''' + hotel= search_room(country) + if not hotel: return False + if country == hotel.country and city == hotel.city: return True +def reservations(country,city, room_type): + pass + +def booking(): + pass +def main(): + pass + +if __name__ == "__main__": + print(search_room("Spain", "Madrid")) \ No newline at end of file diff --git a/hotels_easy.py b/hotels_easy.py new file mode 100644 index 0000000..7277921 --- /dev/null +++ b/hotels_easy.py @@ -0,0 +1,54 @@ +from login import login + + +'''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.''' + +rooms={"single":3, "vip":6, "double":6, "group":6, "luxury":3} + +hotels={ + "Spain":{"Madrid":rooms, "Barcelona":rooms, "Valencia": rooms}, + "France":{"Paris":rooms,"Marseille":rooms}, + "Portugal":{"Lisbon":rooms, "Madeira":rooms, "Porto":rooms}, + "Italy":{"Rome":rooms, "Milan":rooms}, + "Germany":{"Munich":rooms, "Berlin":rooms}} + +def isavailable(country:str, city:str, room:str)->bool: + return hotels[country][city][room]>0 + +def reservation(country:str, city:str, room:str)->bool: + if isavailable(country, city, room): + hotels[country][city][room]-=1 + return True + + return False + + + +def main(): + username=input("Please insert your username. ") + password=input("Please insert your password. ") + control="y" + if login(username,password): + while control=="y": + country=input(f"type the country of your preference {list(hotels.keys())}").capitalize() + city=input(f"type the city of your preference {list(hotels[country].keys())}").capitalize() + room=input(f"type the room of your preference{list(hotels[country][city].keys())}") + + if reservation(country, city, room): + print("Success!") + else: + print("Sorry") + control=input("Do you want to continue? y/n").lower() + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/login.py b/login.py new file mode 100644 index 0000000..81f2c02 --- /dev/null +++ b/login.py @@ -0,0 +1,53 @@ +class User: + budget:int + reservation:list + def __init__(self, name:str, id:int, password:str, passport:int, budget=600,reservation=[]) -> None: + self.name = name + self.id = id + self.password = password + self.passport = passport + self.budget =budget + self.reservation=reservation + + +users=[User(name="Mayber", id=1126785, password="pass", passport=122345), + User(name="Tony", id=34657212, password="reto1", passport=126345)] + +def search_user(userid:int)->User | bool: + ''' + hace una búsqueda del usuario en las credenciales almacenadas si el usuario existe. + + :param: userid:str - ID proporcionado por el usuario. + :return: object or error - objeto resultante contiene datos del usuario. + + ''' + user= filter(lambda user: user.name == userid, users) + try: + return list(user)[0] + except: + return False + +def isvalid(userid:int, password:str)->bool: + ''' + valida que las credenciales pertenezcan al usuario. + + :param: userid, password: str - ID y Password proporcionados por el usuario. + :return: bool - son correctas ambas credenciales? + ''' + user= search_user(userid) + if not user: + return False + if userid == user.name and password == user.password: + return True + +def login(userid:str, password:str): + for i in range(3): + isvalid(userid, password) + if isvalid(userid, password): + print("Success!") + return True + elif i == 2: + print("You're blocked.") + return False + else: + print(f"you have {i} tries left") \ No newline at end of file diff --git a/manchester.py b/manchester.py new file mode 100644 index 0000000..222f3e4 --- /dev/null +++ b/manchester.py @@ -0,0 +1,94 @@ +'''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. +''' + +class Player: + + def __init__(self,name:str,goals:int, speed:int, assists:int, passaccuracy:int, defense:int) -> None: + self.name=name + self.goals=goals + self.speed=speed + self.assists=assists + self.passaccuracy=passaccuracy + self.defense=defense + + def __repr__(self) -> str: + return f"name: {self.name}\n goals: {self.goals}\nspeed: {self.speed}\nassists: {self.assists}\npass accuracy: {self.passaccuracy}\ndefense: {self.defense}\n" + + +players = { + 8:Player("Bruno Fernandes", 5, 6, 9, 10, 3), 11:Player("Rasmus Hojlund", 12, 8, 2, 6, 2), + 5:Player("Harry Maguire", 1, 5, 1, 7, 9), 17:Player("Alejandro Garnacho", 8, 7, 8, 6, 0), + 7:Player("Mason Mount", 2, 6, 4, 8, 1) + } +def search_player(number:int)->bool: + return True if number in players.keys() else False +def player_review(number:int)->Player: + return players[number] if search_player(number) else "The player isn't listed or doesn't exist" + +def comparison(player1:int,player2:int)->Player: + if search_player(player1) and search_player(player2):return players[player1], players[player2] + else: return print("The player isn't listed or doesn't exist") + +def top_player_by(stat:str): + if stat in ["goals", "speed", "assists", "passaccuracy", "defense"]: + return max(players.values(), key=lambda item: getattr(item, stat)) + else: + print("Try again, maybe you had a Typo.") + return top_player_by(stat) + +def main(): + choice = int(input("choose between the following options:\n1. Player review.\n2. Compare two players of your choice.\n3. The top player by a stat of your choice.\n4. Exit.\n")) + control = "y" + def return_to_menu(control): + control=input("do you want to return to the main menu? y/n") + if control =="y": + return main() + else: print("Thank you for using the player system. Good bye!") + + match(choice): + case 1: + number = int(input("Type the player's number.")) + print(player_review(number)) + return_to_menu(control) + + case 2: + player1= int(input("Type the first player's number.")) + player2= int(input("Type the second player's number.")) + print(comparison(player1,player2)) + return_to_menu(control) + case 3: + stat=input("Type the stat you want to review:\ngoals, speed, assists, passaccuracy, defense") + print(top_player_by(stat)) + return_to_menu(control) + case 4: + print("Thank you for using the player system. Good bye!") + case _: + print("incorrect option.") + main() +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/travel_agency.py b/travel_agency.py new file mode 100644 index 0000000..1b11344 --- /dev/null +++ b/travel_agency.py @@ -0,0 +1,58 @@ +'''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''' + +budget = { + 100:{"Winter":{"Andorra":"You can go to skiing activities","Switzerland":"You can go on a tour to the Swiss Alps"}}, + 200:{ + "Winter":{"Andorra":"You can go to skiing activities","Switzerland":"You can go on a tour to the Swiss Alps"}, + "Autumn":{"Belgium":"there are hiking and extreme sports activities", "Australia":"there are cultural and historical activities"} + }, + 300:{ + "Winter":{"Andorra":"You can go to skiing activities","Switzerland":"You can go on a tour to the Swiss Alps"}, + "Autumn":{"Belgium":"there are hiking and extreme sports activities", "Australia":"there are cultural and historical activities"}, + "Spring":{"France":"there are extreme sports activities", "Italy":"there's a cultural and historical tour"} + }, + 400:{ + "Winter":{"Andorra":"You can go to skiing activities","Switzerland":"You can go on a tour to the Swiss Alps"}, + "Autumn":{"Belgium":"there are hiking and extreme sports activities", "Australia":"there are cultural and historical activities"}, + "Spring":{"France":"there are extreme sports activities", "Italy":"there's a cultural and historical tour"}, + "Summer":{"Spain":"there are hiking and extreme sports activities", "Portugal":"there are activities on the beaches"} + } +} + +def choose_budget(key:int): + if key >=400: + return budget[400] + elif key >=300: + return budget[300] + elif key >=200: + return budget[200] + elif key >=100: + return budget[100] + + +def destination(budgetkey:int, season:str, country:str): + return f"{country}: {choose_budget(budgetkey)[season][country]}" + +def main(): + budgetkey=int(input("Welcome, please type your budget.")) + if budgetkey <100: + print("Sorry, you don't have enoguh funds.") + else: + print(f"Based on your budget, we recommend you these seasons to travel: {list(choose_budget(budgetkey).keys())}") + season=input("please type the season you'd like among the available options. ") + country=input(f"please type the country you'd like among the options.\n {list(choose_budget(budgetkey)[season].keys())} ") + print(f"this is your choice and the activities that come with the offer:\n{destination(budgetkey, season, country)}") + print("Thank you for using our services.") + +main() \ No newline at end of file diff --git a/turkish_airlines.py b/turkish_airlines.py new file mode 100644 index 0000000..8ae6dc8 --- /dev/null +++ b/turkish_airlines.py @@ -0,0 +1,49 @@ +'''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. -> listo +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. -> listo. +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. ->listo. +The program must collect the following data: Name, country of origin, passport, and destination country. -> listo +Upon completing the process, the system will display everything the user has previously chosen along with their information. -> listo +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 login import login + +meals = {1:"Regular", 2:"Vegetarian", 3: "Kosher"} +destination = ["Turkey", "Greece", "Lebanon", "Spain", "Portugal"] +flight_schedule = {1:"monday 22/02",2:"friday 25/02",3:"thursday 04/03",4:"wednesday 10/03",5:"saturday 13/03", 6:"monday 15/03"} +logs={} +def purchase(): + pass + +def userdata(name:str, origin:str, destination:str, passport:int, flight_class: str, outbound_date:str, return_date:str, additional:bool): + user_data={"Name":name, "Country of Origin": origin, "Destination":destination, "Passport": passport} + flight_data={"class": flight_class, "luggage": "hand | additional: "+additional, "flight date": ["outbound: "+outbound_date, "return: "+return_date]} + + return f"Your data: {user_data}, your flight information: {flight_data}" + +def main(): + username=input("Please insert your username. ") + password=input("Please insert your password. ") + if login(username, password): + name=input("insert your Name") + passport=input("insert your passport") + origin = input("type country of origin ") + destination=input(f"choose your destination {destination} ") + outbound_date=input(f"choose outbound date: {flight_schedule}") + return_date=input("choose return date: ") + flight_class=input("choose the class: ") + additional=input("do you want to carry aditional luggage? y/n").upper() + details=userdata(name, origin, destination, passport, flight_class, outbound_date, return_date, additional) + print(details) + + purchase= input("do you want to confirm this transaction? y/n").lower() + if purchase == 'y': + logs[username]=details + print(logs) + else: print("thank you, come again!") + +main() + + \ No newline at end of file