1

I'm dealing with the value of inputs.The input should be rounded down to nearest hundred. For example, if the input is 5398 euros, the input is determined using value 5300 euros.

Julie Wei
  • 21
  • 3

2 Answers2

1

You can do that by taking the integer part of the number divided by 100 and then multiplying by 100:

rounded = int(your_number / 100) * 100
Jerzy Pawlikowski
  • 1,751
  • 19
  • 21
1

You may use either of these three ways (there may exist many more ways):

import math
print(math.floor(5398 / 100.00) * 100)

Output is 5300 as expected.

rounded = int(5398 / 100) * 100
print(rounded)

Still the output is 5300.

import numpy
print(int(numpy.floor(5398 / 100.0) * 100))

The output is still 5300 :)

Have Fun :)

Saeed
  • 3,255
  • 4
  • 17
  • 36