Ask Question
11 May, 05:45

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
Answers (1)
  1. 11 May, 07:22
    0
    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

    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.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “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 ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers