Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Checking if a number is even without built-in functions [closed]

$
0
0

Given an integer value as input, write a Python script that checks if the number is even or not. The script should print 'True' if it's an even number, and 'False' if it's not. Don't use any built-in Python functions, only simple mathematical operations.

I tried a lot but I just can't find the solution.This was the best I could arrive:

def is_even(n):    if n % 2 == 1:        return False    else:         return True

It looks like I can't use module %.I even tried ChatGPT without success.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>