-2

Example: User needs .5 gallons of paint for a wall. User must purchase entire gallon.

This needs to be rounded up after calculations have taken place or it will affect the math

  • Show the Code you've tried already. – Sam Orozco Apr 13 '16 at 23:28
  • 4
    http://stackoverflow.com/questions/2356501/how-do-you-round-up-a-number-in-python – nathan hayfield Apr 13 '16 at 23:28
  • 1
    Use the math.ceil() function. e.g. final_number = math.ceil(.25) = 1.0, you can then take the int() to remove the decimal point and trailing zero e.g. final_number = int(math.ceil(.25)) = 1.. math also has another built in function math.floor() which rounds down rather than up! Good luck! – TheLazyScripter Apr 13 '16 at 23:39

1 Answers1

-1

Already answered, you can use the ceil function in the math module. How do you round UP a number in Python?

Community
  • 1
  • 1
TasconTT
  • 1
  • 1
  • You can just mark the question as a duplicate if you think it's been answered elsewhere already. Welcome to the site btw. :) – jDo Apr 13 '16 at 23:45
  • Thank you, I think I need some reputation to use flags I don't have that option yet. :) – TasconTT Apr 13 '16 at 23:55