GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — floor() and ceil() function Python - GeeksforGeeks floor() and ceil() function PythonLast Updated : 3 Jun, 2026 Python provides the floor() and ceil() functions in the math module to round numbers.
Output 3 4 Explanation:
Syntax
Parameters: number - A float or integer value. Return Type: Both return an integer. Round a List of FloatsIn this example, floor() and ceil() are applied to each element of a list using the map() function.
Output
Explanation:
Compare floor() and ceil() with Negative NumbersFor negative numbers, floor() and ceil() behave differently compared to positive numbers.
Output
Explanation:
Round User Input to Nearest Integerfloor() and ceil() functions can be used to round a decimal number down or up to the nearest integer. In this example, floor() rounds the number downward, while ceil() rounds it upward.
Output 7 8 Explanation:
Computing Floor and Ceil Without Importing mathWe can also find the floor and ceil values of a number without using the math module. This can be done using integer division (//) and simple conditions.
Floor and Ceil using Integer Division
Output Floor of 4.5: 4.0 Ceil of 4.5 : 5.0 Floor of -4.5: -5.0 Ceil of -4.5 : -4.0 Explanation:
Related Articles:Comment Explore |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |