0

Can any one say how to do the program to find even or odd without using conditional operators.

i do this program but the problem is both even & odd in printing in my output statements

30th Jun 2017, 2:03 AM
Surya Teja Maddala
Surya Teja Maddala - avatar
9 Respuestas
+ 1
num=int(input("enter a number")) print("the number is:",num) num%2==0 print("even") num%2==1 print("odd")
30th Jun 2017, 2:05 AM
Surya Teja Maddala
Surya Teja Maddala - avatar
0
use bitwise operations and dictionary.
30th Jun 2017, 2:57 AM
Venkatesh Pitta
Venkatesh Pitta - avatar
0
can ha i used bitwise also that what i am saying both even and odd are printing so plz can u right the code and post wth in 10mins
30th Jun 2017, 3:02 AM
Surya Teja Maddala
Surya Teja Maddala - avatar
0
plz
30th Jun 2017, 3:03 AM
Surya Teja Maddala
Surya Teja Maddala - avatar
0
I can't give you working program. May be later. Here's an idea. Use the dictionary to map 0 to even and 1 to odd. Then call the bitwise and of 1 and your input into the dictionary. Ta Da!! I know, right?!
30th Jun 2017, 3:26 AM
Venkatesh Pitta
Venkatesh Pitta - avatar
0
no & 1 && print("odd")|| print("even") like this only na ??
30th Jun 2017, 3:28 AM
Surya Teja Maddala
Surya Teja Maddala - avatar
0
can any plz say the answer
1st Jul 2017, 12:51 AM
Surya Teja Maddala
Surya Teja Maddala - avatar
0
don't give me hints if your free then plz pus ( the code) progam
1st Jul 2017, 12:53 AM
Surya Teja Maddala
Surya Teja Maddala - avatar