How bad is this method of getting Even/Odd? /u/VanClyded Python Education

Been getting back into Python and i needed to find even/odd numbers in a short list, came up with a ridiculous line of code that seem… to work?
Example using said line of code;

num = input(“Number: “) if float(num)/2 – int(int(num)/2) == 0: print(“EVEN”) else: print(“ODD”)

So my question is, am i just lucky or is this a *appropriate* way to get this?

submitted by /u/VanClyded
[link] [comments]

​r/learnpython Been getting back into Python and i needed to find even/odd numbers in a short list, came up with a ridiculous line of code that seem… to work? Example using said line of code; num = input(“Number: “) if float(num)/2 – int(int(num)/2) == 0: print(“EVEN”) else: print(“ODD”) So my question is, am i just lucky or is this a *appropriate* way to get this? submitted by /u/VanClyded [link] [comments] 

Been getting back into Python and i needed to find even/odd numbers in a short list, came up with a ridiculous line of code that seem… to work?
Example using said line of code;

num = input(“Number: “) if float(num)/2 – int(int(num)/2) == 0: print(“EVEN”) else: print(“ODD”)

So my question is, am i just lucky or is this a *appropriate* way to get this?

submitted by /u/VanClyded
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *