Assignment 4: Evens and Odds


n = int(input("How many numbers do you need to check? "))
even = 0
odd = 0
for x in range(n):
num = int(input("Enter number: "))
if num % 2 == 0:
print(str(num) + " is an even number.")
even += 1
else:
print(str(num) + " is an odd number.")
odd += 1
print("You entered "+str(even)+" even number(s).")
print("You entered "+str(odd)+" odd number(s).")
This works for me. Best of luck.
The program checks if user supplied integers are even or odd and displays the appropriate value. The program is written thus in python 3 ;
n_check = int(input("How many numbers do you need to check? "))
#number of values user wishes to test
even_count = 0
odd_counts = 0
for n in range(n_check):
num = int(input("Enter number: "))
if num % 2 == 0:
#even numbers leave no remainder when divided by 2
print(str(num) + " is an even number.")
even_counts+= 1
#increase count of even numbers
else:
print(str(num) + " is an odd number.")
odd_counts += 1
print("You entered "+str(even_counts)+" even number(s).")
print("You entered "+str(odd_counts)+" odd number(s).")
#display the number of even and odd numbers entered.
Learn more : https://brainly.com/question/24171161