0

So I am trying to use the built-in round function in Python but for some reason, the program runs properly sometimes and other times it doesn't

for i in range(0, inp):
    temp = restaurant.getEmployee() * random.randint(1, 5) * hours * average
    print(round(temp, 2))
    weekly += round(temp, 2)
    restaurant.changeMoney(round(temp, 2))

print("\nThe restaurant earned $" + str(weekly))
print("The restaurant has a total of $" + str(restaurant.getMoney()))

This is the result that I get:

3622.32
1448.93
724.46
1448.93
3622.32

The restaurant earned $10866.960000000001
The restaurant has a total of $11266.960000000001

Sometimes the code works properly and I get something along the lines of this:

3421.44
684.29
684.29
2737.15
3421.44

The restaurant earned $10948.61
The restaurant has a total of $11248.61
venus
  • 1
  • 1

0 Answers0