152k views
0 votes
Create Python program code that will use a for loop to ask the user to enterfourintegers. Itwillcount how many of the integers are divisible by 2. The programwill print each of the 4integers and a message saying whether the integeris even or odd. The code will print the total number of even integers

1 Answer

4 votes

Answer:

is_even = 0

int_numbers = []

for n in range(4):

n = int(input('press any four integer numbers')

int_numbers.append(n)

for n in int_numbers:

if n%2==0:

print(n, 'integer is even')

is_even+= 1

else:

print(n, 'integer is odd')

print('Total even numbers =', is_even)

Step-by-step explanation:

is_even = 0 (initiates a counter to record the number of even integers).

int_numbers creates a list to store the inputs entered by the user.

int(input()) : allows users to enter an integer number

int_numbers.append(n) : adds user input to list list variable created.

n%==2 : checks if entered digit leaves a remainder of 0 when divided by 2; hence an even number

is_even+= 1: counter updates by 1 for every even number confirmed.

Create Python program code that will use a for loop to ask the user to enterfourintegers-example-1
User Prasanth Regupathy
by
4.9k points