Python - Check If Number Is An Integer

Опубликовано: 28 Сентябрь 2024
на канале: codevev
1,083
19

#Python #Shorts
Sometimes you may want to check if the result you get after performing some math operation is the whole number.
Python makes it easy for us to do this by calling the "is_integer" method on a float.
For example, if we have code like x = 5 / 2, we can do x.is_integer() to check if it's a whole number or not (it isn't since 5 / 2 is 2.5).

-------------------------------------------------------------------------------------
Links:
Blog: https://evgenyurubkov.com
Twitter:   / evgenyurubkov  
Instagram:   / evgenyurubkov  
Youtube:    / @codevev