floor & ceil math functions

All Math methods


Youtube Live session on Tkinter

ceil function returns lowest integer higher than the input.
Here are some examples with different type of numbers.
print(math.ceil(1.2))  # 2
print(math.ceil(1.6))  # 2 
print(math.ceil(-1.2)) # -1
print(math.ceil(-1.6)) # -1
print(math.ceil(45))   # 45
floor function returns highest integer lower than the input.
print(math.floor(1.2))  # 1
print(math.floor(1.6))  # 1 
print(math.floor(-1.2)) # -2
print(math.floor(-1.6)) # -2
print(math.floor(45))   # 45
We can use type() to get the data type.
import math
x=math.floor(-1.2) 
print(x) # -2
print(type(x)) # <class 'int'>

Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer