+ 2

How to write if not equal to in python 3?

Means we write if x%1==0 print("whole number") then how to write if x%1 is not = 0 then write irrational number?

28th May 2018, 8:03 AM
Prajjwal
Prajjwal - avatar
2 ответов
+ 3
if x % 1 != 0: print("Whole number")
28th May 2018, 9:46 AM
TurtleShell
TurtleShell - avatar
+ 3
% only works on integers. if x == int(x): print("whole number") else: #or if x != int(x): print("not a whole number")
28th May 2018, 8:12 AM
Vlad Serbu
Vlad Serbu - avatar