From d0db8c92ba1b425b875eae32538a378ff808bf96 Mon Sep 17 00:00:00 2001 From: govind Date: Mon, 14 Oct 2019 18:54:18 +0530 Subject: [PATCH] changed ifEvenorOdd.py --- Loops&Conditionals/ifEvenorOdd.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Loops&Conditionals/ifEvenorOdd.py b/Loops&Conditionals/ifEvenorOdd.py index 519cbfa..3c71847 100644 --- a/Loops&Conditionals/ifEvenorOdd.py +++ b/Loops&Conditionals/ifEvenorOdd.py @@ -1,7 +1,7 @@ #checks if a given number is even or not num = int(input("Enter your number:")) #input takes a string value so it must be casted to int -if(num % 2 == 0): #if number / 2 gives a remainder 0 it is even else odd - print("Even") -else: +if (n&1): # ANDing with 1 checks if a number is odd , useful for large numbers print("odd") +else: + print("even")