Reputation: 9
I am creating a fitness wearable device python program that tracks the distance its users walk or run daily. To motivate the users to meet and exceed the target distance, it rewards users with fitness points on a leadership board for the users who meet and exceed the target distance in a week.
The fitness point is calculated with a minimum distance of 32 km per week, and the points for each km in excess of the minimum distance is show as follow:
How do I make the points calculate progressively.
def fitness_app(distance):
while True:
distance = int(input("Please Enter Distance in Km: "))
if 0 > distance < 32:
fitness_pt = 0
print(fitness_pt)
elif 33 > distance < 40:
fitness_pt = 325 * distance
print(fitness_pt)
elif 41 > distance < 48:
fitness_pt = 550 * distance
print(fitness_pt)
elif distance > 48:
fitness_pt = 600 * distance
print(fitness_pt)
print(fitness_app(distance=True))
Upvotes: 0
Views: 209
Reputation: 39404
I think you're almost there, just that the comparisons don't need to be so complicated:
def fitness_app():
while True:
distance = int(input("Please Enter Distance in Km: "))
if distance < 32:
fitness_pt = 0
elif distance < 40:
fitness_pt = 325 * distance
elif distance < 48:
fitness_pt = 550 * distance
else:
fitness_pt = 600 * distance
print(fitness_pt)
fitness_app()
Note: other superfluous complications also removed.
Upvotes: 1