Ask Question
15 December, 11:50

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.

+3
Answers (1)
  1. 15 December, 13:58
    0
    """

    Python program code that will ask the user to enter four integers.

    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.

    """

    integer = []

    count = 0

    even = 0

    while count < 4:

    entry = int (input ('Enter an integer: '))

    integer. append (entry)

    count = count + 1;

    for num in integer:

    if num % 2 = = 0:

    print ("The integer " + str (num) + " is even")

    even = even + 1

    else:

    print ("The integer " + str (num) + " is odd")

    print ("The total number of even integers is " + str (even))

    Explanation:

    The while loop keeps executing provided the number of entry inputted is less than 4. Once it is up to 4, it stops.

    The for loop is used to iterate over a list "integer", to test if the integers in it are even or odd.

    The condition for even is the number whose remainder is zero after divided by 2. The symbol "%" used in the code, calculates the remainder after division. The numbers that have a remainder are odd.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers