Assignment 4: Evens and Odds python
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.
Hint: For a number to be even, when the number is divided by 2, there should be no remainder - so you will want to use the modulus (%) operator.
Hint: You will need two count variables to keep track of odd and even numbers.
Sample Run 1
How many numbers do you need to check? 5
Enter number: 20
20 is an even number.
Enter number: 33
33 is an odd number.
Enter number: 4
4 is an even number.
Enter number: 77
77 is an odd number.
Enter number: 8
8 is an even number.
You entered 3 even number(s).
You entered 2 odd number(s).
Sample Run 2
How many numbers do you need to check? 3
Enter number: 10
10 is an even number.
Enter number: 3
3 is an odd number.
Enter number: 400
You entered 2 even number(s).
You entered 1 odd number(s).
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).”
please answer I'm having a difficult time and it's due today
Answers
Answer:
Explanation:
Python program to count the number of even.
Generally, use for loops when you have a defined range of values to iterate over. Use while loops when you aren't iterating, or don't know when your exit condition will be true. could confuse some people and cause off-by-one errors.
remainder value. The result of x%y is obtained by(x-(x/y)*y). This operator is applied only to integral operands and cannot be applied to float or double.
An odd number can only be formed by the sum of an odd and even number (odd + even = odd, or even + odd = odd). An even number can only be formed by multiplication in three ways: even·odd, odd·even, and even·even. An odd number can only be formed by multiplication in one way: odd·odd = odd.
The sum of an even number and an odd number is odd. The product of two even numbers is even. The product of two odd numbers is odd.
The product of two or more odd numbers is always odd. The sum of an even number of odd numbers is even, while the sum of an odd number of odd numbers is odd.
No results found for 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).”.
please mark as brainliest