While16. The sportsman-skier began training, running the first day 10 km. Every other day he increased the mileage by P percent from the previous day's run (P is real, 0 < P < 50). For this P, determine after which day the total run of the skier for all days exceeds 200 km, and display the number of days K (the integer) and the total mileage S (real number).

Solution in Python 3:

import random

Daily = 10
Total = 200

P = random.randrange(1,51)
#P = 7
print('P = ', P)
coef = 1 + P/100
print("First Day = {0}, Percent = {1}, Coef = {2}".format(Daily,P,coef))
K = 1
S = Daily
while S < Total:
Daily *= coef
S += Daily
K += 1
print("K = {0}, Daily = {1}, S = {2}".format(K,Daily,S))

print()
print("Days = {0}, Summary = {1}".format(K,S))