The program takes weighted strengths of the human body (arms/legs/core/mind) based on the required attributes for a sport, then tells you the resulting sport. The program is obviously really ugly. Is there a way I could use dictionaries and a lambda function to find a max instead? This latter part is what I don't know how to do.
print("Welcome to What's your ideal sport! Answer the following questions on a scale from 1-10.")
leg_strength = int(input("How good is your leg strength / speed?"))
arm_strength = int(input("How good is your arm strength?"))
core_strength = int(input("How strong are your abs?"))
mental_strength = int(input("How intelligent are you?"))
reaction_time = int(input("How fast are your reactions?"))
# Sports are: Soccer, Football, Tennis, Swimming, Basketball, Track, Gymnastics, and Chess.
sports = []
soccer = (arm_strength*5) + (reaction_time*2) + (mental_strength) + (arm_strength) + (core_strength)
sports.append(soccer)
chess = mental_strength * 10
sports.append(chess)
football = (arm_strength*4) + (core_strength*3) + (leg_strength*3)
sports.append(football)
tennis = (reaction_time*3) + (arm_strength*4) + (core_strength*2) + (mental_strength)
sports.append(tennis)
swimming = reaction_time + (core_strength*3) + (arm_strength*3) + (leg_strength*3)
sports.append(swimming)
basketball = (leg_strength*2) + (arm_strength*5) + (mental_strength*2) + core_strength
sports.append(basketball)
track = (leg_strength*6) + (arm_strength*2) + (reaction_time) + (mental_strength)
sports.append(track)
gymnastics = (leg_strength*3) + (arm_strength*3) + (core_strength*3) + mental_strength
sports.append(gymnastics)
print(sports)
best = max(sports)
sports.index(best)
indices = []
for sport in sports:
if sport == best:
indices.append(sports.index(sport))
result = []
for index in indices:
if index == 0:
result.append("Soccer")
elif index == 1:
result.append("Chess")
elif index == 2:
result.append("Football")
elif index == 3:
result.append("Tennis")
elif index == 4:
result.append("Swimming")
elif index == 5:
result.append("Basketball")
elif index == 6:
result.append("Track")
elif index == 7:
result.append("Gymnastics")
print("Your best olympic sport(s) are: {0}.".format(result))