-1

distance = 10

total = 0

for days in range (1,15):

total += distance
print ("Day", days, "travelled",  distance, "miles", "total" , total )
distance *= .8
Jason_int
  • 3
  • 1
  • Did you really bother searching for this before posting? There are dozens of questions about printing a certain number of decimal places. – Barmar Sep 28 '17 at 02:55
  • @Barmar that's the wrong dupe, that's with the `Decimal` type, not generic floats. – Nick T Sep 28 '17 at 02:57

1 Answers1

0

You can use the ``round" function

distance = 10
total = 0

for days in range (1,15):
    total += distance
    print ("Day", days, "travelled",  round(distance, 2), "miles", "total" , round(total, 2) )
    distance *= .8
Xero Smith
  • 1,968
  • 1
  • 14
  • 19