我正在尝试编写一个简单的程序,它接收您之前运行的距离和时间,接收新的距离和时间,然后显示新距离和时间的平均英里步速。我试图让它继续循环这些输入,直到用户输入'ALL DONE',一旦他们键入我想要编程以显示你已经运行的总距离,你运行的总时间,以及你的总平均英里数步伐。我一直在无休止地调整我的代码并在Google上搜索信息,但我只是没有成功。这是我到目前为止所拥有的。
firstD = float(input("Please tell me the previous total distance in miles: "))
firstT = float(input("Please tell me the previous total time in minutes: "))
newD = float(input("Please tell me the most recent running distance in miles: "))
newT = float(input("Please tell me the most recent running time in minutes: "))
newTd = firstD + newD
newTt = firstT + newT
averageTp = newTt / newTd
averageSp = newT / newD
while firstD != str("ALL DONE"):
print("Average pace for this session:", averageSp)
if firstD == str("ALL DONE"):
print("New total distance:", newTd)
print("New total time:", newTt)
print("Average Total Pace:", averageTp)
else:
break