+ 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?
2 ответов
+ 3
if x % 1 != 0:
print("Whole number")
+ 3
% only works on integers.
if x == int(x):
print("whole number")
else: #or if x != int(x):
print("not a whole number")