Computer Science, asked by sajedamurad777, 6 months ago

Assignment 4: Evens and Odds
Write a program that will ask a user for how many numbers they would like to check. Then, using a for loop, prompt the user for a number, and output if that number is even or odd. Continue doing this as many times as the user indicated. Once the loop ends, output how many even numbers were entered and how many odd numbers were entered.
Benchmarks
Prompt the user to answer the question, “How many numbers do you need to check? “
Create and initialize two count variables - one for odd and one for even.
Based on the previous input, create a for loop that will run that exact number of times.
Prompt the user to “Enter number: “
If that number is even, output “[number] is an even number.”
Update the even count variable.
Or else if the number is odd, output “[number] is an odd number.”
Update the odd count variable.
Output “You entered [number] even number(s).”
Output “You entered [number] odd number(s).”
(This is my code I dont understand why its not passing all 5 tests)
num = int(input("How many numbers do you need to check? "))
e = 0
o = 0

for i in range(num):
x = int(input("Enter number: "))
if(x % 2 == 0):
print(str(x) + " is an even number.")
e = e + 1
if(x % 2 == 1):
print(str(x) + " is an odd number.")
o = o + 1

print("You entered " + str(e) + " even number(s).")
print("You entered " + str(o) + " odd number(s).")

Answers

Answered by raisha5
0

Answer:

0000000000000000

hdhdyyd hejejejjek ISIS

jeidid

kekrk

mekr

Similar questions