Python Code: Enter 5 numbers, the program check each number, tells how many numbers are even and odd numbers. 1. Create Function.py, create a function, "CheckEvenOdd(num)", print a message to tell this is number is even or odd, returns 1 if num is even, returns 0 if odd. 2. Create Run.py, import func.py to run.py, have users to enter five numbers, call "CheckEvenOdd(num)" on each number. tells how many numbers are even and odd numbers.
Python Code:
Enter 5 numbers, the program check each number, tells how many numbers are even and odd numbers.
1. Create Function.py, create a function, "CheckEvenOdd(num)", print a message to tell this is number is even or odd, returns 1 if num is even, returns 0 if odd.
2. Create Run.py, import func.py to run.py, have users to enter five numbers, call "CheckEvenOdd(num)" on each number. tells how many numbers are even and odd numbers.
-------------------------------------------------------------------------------------------------------------------------
Guide:
numbers = 0
evenCount = 0
oddCount = 0
"enter a number: "
if numbers % 2 == 0:
evenCount += CheckEvenOdd(num)
else:
oddCount += CheckEvenOdd(num)
"Total even nubmers: " evenCount ", " "Total oddnubmers: " oddCount
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images