Monday, January 13, 2025
HomeQ&Afloor() and ceil() function Python

floor() and ceil() function Python

In Python, floor() and ceil() are mathematical functions provided by the math module.

math.floor(x) returns the largest integer less than or equal to x, effectively rounding down any decimal value. For example, math.floor(3.7) would return 3.

See also  Types of Network Topology

math.ceil(x) returns the smallest integer greater than or equal to x, effectively rounding up any decimal value. For example, math.ceil(3.2) would return 4.

Both functions are useful for controlling the rounding of numbers when performing mathematical or financial calculations. They only work with numerical inputs.

See also  Which country has the code plus 67?

 

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x