how to determine base key? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how to determine base key?

in this case i want to find even number when user put a negative input as number now how can find this is a even or odd when base key is x == 0

26th Sep 2018, 9:29 AM
Hamid Reza Imany Khoshkhoo
Hamid Reza Imany Khoshkhoo - avatar
1 Answer
0
I am not sure I got your question right, but the easiest way to check if an integer is even or not is to bitwise AND it with 1 (var&1), like this: a=1 print("the number is "+"not "*(a&1)+"even")
26th Sep 2018, 10:46 AM
strawdog
strawdog - avatar