Google News
logo
Python Program to Round a number upwards and downwards to its nearest integer
In the following example of Python program to round a number upwards and downwards to its nearest integer :
Program :
import math

num = 3.5

# Round num upwards to its nearest integer
up_num = math.ceil(num)

# Round num downwards to its nearest integer
down_num = math.floor(num)

print("Original number:", num)
print("Rounded upwards number:", up_num)
print("Rounded downwards number:", down_num)
Output :
Original number: 3.5
Rounded upwards number: 4
Rounded downwards number: 3