asked 40.4k views
1 vote
4. Create Python program code that will use a for loop to ask the user to enter four integers. It will count how many of the integers are divisible by 2. The program will print each of the 4 integers and a message saying whether the integer is even or odd. The code will print the total number of even integers

1 Answer

3 votes

Answer:

Following are the program in Python Programming Language:

le = [] #set list type variable

for k in range(4): #set for loop

le.append(int(input("Enter the integer value:: "))) #get input from the user

count1 = 0 #set integer type variable

for num1 in le: #set for loop

if num1 % 2 == 0: #set if statement

print(num1 ,"is even.") #print output

count1 += 1 #increament count

else: #set else statement

print(num1, "is odd") #print output

print("The total Number of even numbers entered is", count1)

#print output

Output:

Enter the integer value:: 20

Enter the integer value:: 25

Enter the integer value:: 50

Enter the integer value:: 55

20 is even.

25 is odd

50 is even.

55 is odd

The total Number of even numbers entered is 2

Step-by-step explanation:

Here, we define a list type variable.

Then, we set the for loop which runs the 4 times inside it . We set the condition of if statement and check variable num1 is divided by 2 . If it is even then print num1 is even otherwise print num1 is odd.

and finally it print the total number of even number.

answered
User AustinT
by
7.9k points

No related questions found

Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.