15,614,257 members
1.00/5 (1 vote)
See more:
Have the function MathChallenge (num) check whether every single number in the passed in parameter is even. If so, return the string true, otherwise return the string false. For example: if num is 4602225 your program should return the string false because 5 is not an even number

What I have tried:

Python
```m = int(input("Enter number"))
if m % 2 == 0:
print(m,"is an even number")
else:
print(m,"is an odd number")```
Posted
Updated 20-Jun-22 2:10am
v2
Comments
Richard MacCutchan 1-Dec-21 5:33am
check whether every single number in the passed in parameter is even. If so, return the string true, otherwise return the string false.

## Solution 1

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

Read the question carefully: you have to create a function - which you haven't done - and return a string which gives the result - which you haven't done.
Read your last set of course notes, and it should be easy for you to set up the function and go from there.

## Solution 2

You program works: it produces the expected output. (thanks, Richard) is able to distinguish between even and odd inputs. You have just to wrap the logic in a function returning a boolean value.
Something like
Python
```def MathChallenge(num):
# your logic here

m = int(input("Enter number"))
if MathChallenge(m):
print(m,"is an even number")
else:
print(m,"is an odd number")```

v5
Comments
Richard MacCutchan 1-Dec-21 7:34am
Not according to the instructions in the question. :)
CPallini 1-Dec-21 7:38am
True.

## Solution 6

Go check out coding with mosh 6 hour python tutorial near 2 hour mark he was telling something like this maybe.i didn't check it as I hadn't reached till there.but that may help u

## Solution 4

#solution 2
Python
```def MathChallenge(num):
return num % 2
m = int(input("Enter number"))
if MathChallenge(m) == 0:
print("{} is an even number".format(m))
else:
print("{} is an odd number".format(m))```

v2
Comments
CHill60 12-Mar-22 4:22am
You have added nothing new to the thread with this un-commented code dump

## Solution 5

def MathChallenge(num):
if num%2==0:
print(f'{num} is an even number')
else:
print(f'{num} is an odd number')

Comments
Richard Deeming 20-Jun-22 8:17am
An uncommented code dump, which is virtually identical to solution 4, adds nothing to this thread.

And you don't help anyone by doing their homework for them. Especially not 6½ months late!

And finally, your chosen username make you look like a potential spammer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 OriginalGriff 85 CPallini 50 Graeme_Grant 50 CHill60 40 Rick York 20
 OriginalGriff 2,921 Richard MacCutchan 1,236 Graeme_Grant 940 Dave Kreskowiak 641 CPallini 330

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900