You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
268 B
Python
12 lines
268 B
Python
5 years ago
|
import math
|
||
|
|
||
|
def roundup(a, digits=0):
|
||
|
n = 10**-digits
|
||
|
return round(math.ceil(a / n) * n, digits)
|
||
|
|
||
|
x = 123.01247
|
||
|
print("Original Number: ",x)
|
||
|
print(roundup(x, 0))
|
||
|
print(roundup(x, 1))
|
||
|
print(roundup(x, 2))
|
||
|
print(roundup(x, 3))
|