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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added __pycache__/login.cpython-312.pyc
Binary file not shown.
Binary file added __pycache__/manchester.cpython-312.pyc
Binary file not shown.
33 changes: 33 additions & 0 deletions hospital.py
Original file line number Diff line number Diff line change
@@ -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
72 changes: 72 additions & 0 deletions hotels.py
Original file line number Diff line number Diff line change
@@ -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"))
54 changes: 54 additions & 0 deletions hotels_easy.py
Original file line number Diff line number Diff line change
@@ -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()
53 changes: 53 additions & 0 deletions login.py
Original file line number Diff line number Diff line change
@@ -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")
94 changes: 94 additions & 0 deletions manchester.py
Original file line number Diff line number Diff line change
@@ -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()
58 changes: 58 additions & 0 deletions travel_agency.py
Original file line number Diff line number Diff line change
@@ -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()
Loading