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
123 changes: 123 additions & 0 deletions ManU.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
'''

1. Manchester United FC has hired you as a developer. Develop a program that helps the coach identify their fastest player, player with the most goals, assists,
passing accuracy, and defensive involvements.
The system should also allow comparison between two players. Use the following player profiles:

Bruno Fernandes: 5 goals, 6 points in speed, 9 points in assists, 10 points in passing accuracy, 3 defensive involvements. Corresponds to jersey number 8.
Rasmus Hojlund: 12 goals, 8 points in speed, 2 points in assists, 6 points in passing accuracy, 2 defensive involvements. Corresponds to jersey number 11.
Harry Maguire: 1 goal, 5 points in speed, 1 point in assists, 7 points in passing accuracy, 9 defensive involvements. Corresponds to jersey number 5.
Alejandro Garnacho: 8 goals, 7 points in speed, 8 points in assists, 6 points in passing accuracy, 0 defensive involvements. Corresponds to jersey number 17.
Mason Mount: 2 goals, 6 points in speed, 4 points in assists, 8 points in passing accuracy, 1 defensive involvement. Corresponds to jersey number 7.
The program functions as follows: The coach accesses the system and encounters a menu with the following options:

Player Review: By entering the player's jersey number, they can access the player's characteristics.
Compare two players: The system prompts for two jersey numbers and displays the data of both players on screen.
Identify the fastest player: Displays the player with the most points in speed.
Identify the top goal scorer: Displays the player with the most points in goals.
Identify the player with the most assists: Displays the player with the most points in assists.
Identify the player with the highest passing accuracy: Displays the player with the most points in passing accuracy.
Identify the player with the most defensive involvements: Displays the player with the most points in defensive involvements.
The system should also allow returning to the main menu.

'''


players = {'Bruno_Fernandes': [5,6,9,10,3], 'Rasmus_Hojlund': [12,8,2,6,2], 'Harry_Maguire': [1,5,1,7,9],
'Alejandro_Garnacho':[8,7,8,6,0] ,'Mason_Mount': [2,6,4,8,1]}


def display_player(player_name):
print(f'{player_name}')
print(f'Goals: {players[player_name][0]}')
print(f'Speed: {players[player_name][1]}')
print(f'Assists: {players[player_name][2]}')
print(f'Passing Accuracy: {players[player_name][3]}')
print(f'Defensive involvements: {players[player_name][4]}')


def player_review():
print('These are the jersey numbers of your favorite players:')
print('Bruno Fernandes: 8')
print('Rasmus Hojlund: 11')
print('Harry Maguire: 5')
print('Alejandro Garnacho: 17')
print('Mason Mount: 7')

while True:
choice = input('Insert the jersey number of the player you want to check (or "exit" to return): ')
if choice.lower() == 'exit':
break
player_name = None
if choice == '8':
player_name = 'Bruno_Fernandes'
elif choice == '11':
player_name = 'Rasmus_Hojlund'
elif choice == '5':
player_name = 'Harry_Maguire'
elif choice == '17':
player_name = 'Alejandro_Garnacho'
elif choice == '7':
player_name = 'Mason_Mount'

if player_name:
display_player(player_name)
else:
print('Invalid Player')

def compare_players():
print('Enter the jersey numbers of the two players you want to compare:')
player1 = input('Player 1: ')
player2 = input('Player 2: ')

if player1 in players and player2 in players:
print(f'Comparison between {player1} and {player2}:')
print(f'{player1}:')
display_player(player1)
print(f'{player2}:')
display_player(player2)
else:
print('Invalid Players')


def identify_statistic(statistic):
max_player = max(players, key=lambda x: players[x][statistic])
print(f'The player with the highest {statistic}:')
display_player(max_player)


def main():
while True:
print('What do you want to do?')
print('a. Player Review')
print('b. Compare two players')
print('c. Identify the fastest player')
print('d. Identify the top goal scorer')
print('e. Identify the player with the most assists')
print('f. Identify the player with the highest passing accuracy')
print('g. Identify the player with the most defensive involvements')
print('h. Exit')

choice = input('Choose a, b, c, d, e, f, g, or h: ')

if choice.lower() == 'a':
player_review()
elif choice.lower() == 'b':
compare_players()
elif choice.lower() == 'c':
identify_statistic(1)
elif choice.lower() == 'd':
identify_statistic(0)
elif choice.lower() == 'e':
identify_statistic(2)
elif choice.lower() == 'f':
identify_statistic(3)
elif choice.lower() == 'g':
identify_statistic(4)
elif choice.lower() == 'h':
break
else:
print('Invalid option. Please choose again.')

if __name__ == "__main__":
main()
130 changes: 130 additions & 0 deletions doctor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
'''

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 timeslot.

'''



users= {}
specialities = {'General Medicine': ['García', 'Martinez', 'Segovia'], 'Emergency Care': ['Marquez', 'Rodriguez', 'Vega'],'Clinical Analysis': ['García', 'Vega', 'Segovia'],
'Cardiology': ['Rodriguez', 'Marquez', 'Fernandez'], 'Neurology': ['Ibañez', 'Hagen', 'Pinilla'], 'Nutrition': ['Castañ', 'Barbosa', 'Carrión'],
'Physiotherapy': ['Ross', 'Herrera', 'Aparicio'], 'Traumatology': ['Lopez', 'Lamarca', 'Sevilla'], 'Internal Medicine': ['Ross', 'Hagen', 'Barbosa']}
hours = {'morning': ['7h', '8h', '10h'], 'afternoon': ['15h', '16h', '17h']}
appointments = {}


import getpass


def user():
username = input("Enter a username: ")
password = getpass.getpass("Enter a password: ")

if username not in users:
users[username] = {'password': password}
print("Registered successfully.")
else:
print("Username already exists. Please choose a different username.")


def login():

attempts= 0
while attempts < 3:

username = input("Enter a username: ")
password = getpass.getpass("Enter a password: ")
if username in users:
if users[username]['password'] == password:
print("Welcome,", username)
return True, username
else:
attempts += 1
print("Invalid username or password.")
print("Attempts:", attempts, "Remember you only have 3 attempts to access your account.")
else:
print("Invalid username or password.")
else:
print("You cannot access your account. Too many unsuccessful attempts")
return False, None


def appointment():
nuevo_usuario = user()
usuario_existente = login()

logic = True

while logic:
if usuario_existente:
print(specialities.keys())
choose = input('What is the appointment for? ')
if choose in specialities:
doctors = specialities[choose]
print(f' Doctors available for {choose}: {doctors}')

doctor_choice= input('Who do you want to book the appointment with? ')

logic2 = True

while logic2:
if doctor_choice in doctors:
print(f'Choose an hour: {hours}')
time = input('Write the hour here: ')

if time in hours['morning'] or time in hours['afternoon']:
whole_appointment = f'{choose}_{doctor_choice}_{time}'
if whole_appointment not in appointments:
appointments[whole_appointment] = usuario_existente
print(f'Appointment booked successfully with {doctor_choice} for {choose} at {time} time.')
logic = False
logic2 = False
else:
print('You already have an appointment at this time. Please choose another time.')
logic2 = True
else:
print('Invalid time choice. Please choose from the available hours.')
logic2 = True
else:
print('Invalid doctor choice. Please choose a doctor from the available options.')
logic2 = True
else:
print('Invalid specialty choice. Please choose a specialty from the available options.')
logic = True


if __name__ == "__main__":
appointment()







102 changes: 102 additions & 0 deletions flights.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
'''
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.

'''




users = {}
countries = ['Turkey', 'Greece', 'Lebanon', 'Spain', 'Portugal']
classes = ['Economy', 'First Class']
meals = ['Regular', 'Vegetarian', 'Kosher']

def user():
username = input("Enter a username: ")
password = input("Enter a password: ")

if username not in users:
users[username] = {'password': password}
print("Registered successfully.")
else:
print("Username already exists. Please choose a different username.")

def login():
attempts = 0
while attempts < 3:
username = input("Enter a username: ")
password = input("Enter a password: ")
if username in users:
if users[username]['password'] == password:
print("Welcome,", username)
return True, username
else:
attempts += 1
print("Invalid username or password.")
print("Attempts:", attempts, "Remember you only have 3 attempts to access your account.")
else:
print("Invalid username or password.")
else:
print("You cannot access your account. Too many unsuccessful attempts")
return False, None

def book_flight():
user_data = {}
user_exist = login()

if user_exist:
print("Available countries:", countries)
origin_country = input("Choose your origin country: ")
destination_country = input("Choose your destination country: ")

if origin_country in countries and destination_country in countries:
user_data['Origin Country'] = origin_country
user_data['Destination Country'] = destination_country

flight_date = input("Enter the flight date: ")
user_data['Flight Date'] = flight_date

print("Available classes:", classes)
travel_class = input("Choose your travel class (Economy/First Class): ")
if travel_class in classes:
user_data['Travel Class'] = travel_class

luggage_choice = input("Do you want to check an additional piece of luggage? (Yes/No): ")
user_data['Additional Luggage'] = luggage_choice.lower() == 'yes'

print("Available meals:", meals)
meal_choice = input("Choose your preferred meal: ")
if meal_choice in meals:
user_data['Meal Choice'] = meal_choice

user_data['Name'] = input("Enter your name: ")
user_data['Country of Origin'] = input("Enter your country of origin: ")
user_data['Passport'] = input("Enter your passport number: ")

print("\nSummary of your choices:")
for key, value in user_data.items():
print(f"{key}: {value}")

confirm = input("Do you want to confirm the reservation? (Yes/No): ")
if confirm.lower() == 'yes':
print("Reservation confirmed. Thank you for choosing Turkish Airlines!")
else:
print("Reservation canceled. Returning to the main menu.")
else:
print("Invalid meal choice. Returning to the main menu.")
else:
print("Invalid travel class. Returning to the main menu.")
else:
print("Invalid origin or destination country. Returning to the main menu.")
if __name__ == "__main__":
book_flight()

Loading