Even Number Array - Python Programming Exercise

This Python program prompts the user to enter 10 integer numbers and displays only the even numbers from the list. It utilizes a for loop to iterate through the numbers and a conditional statement (if) to check if each number is even. If the number is even, it is printed to the screen; otherwise, it is skipped. The program is an excellent exercise for practicing basic loops and conditional logic in Python. It helps learners understand how to process user input, perform arithmetic checks (like checking if a number is even), and control the flow of a program based on certain conditions. This task reinforces the concept of modulus operations, as checking for even numbers typically involves using the modulus operator (%). By asking the user for input and filtering the even numbers, this program also encourages good practices in terms of handling user input and data validation. It provides a practical example of how to interact with users and process numerical data in a structured way.

 Category

Arrays, Lists, and Strings

 Exercise

Even Number Array

 Objective

Develop a Python program to prompt the user for 10 integer numbers and display the even ones.

 Example Python Exercise

 Copy Python Code
# Program developed by: Programmer 1, Programmer 2

# Initialize an empty list to store the integers
numbers = []

# Prompt the user for 10 integer numbers
for i in range(10):
    number = int(input(f"Enter integer number {i+1}: "))
    numbers.append(number)

# Display the even numbers
print("The even numbers are:")
for number in numbers:
    if number % 2 == 0:
        print(number)

 Output

Enter integer number 1: 4
Enter integer number 2: 7
Enter integer number 3: 10
Enter integer number 4: 11
Enter integer number 5: 14
Enter integer number 6: 18
Enter integer number 7: 21
Enter integer number 8: 24
Enter integer number 9: 25
Enter integer number 10: 30
The even numbers are:
4
10
14
18
24
30

 Share this Python Exercise

 More Python Programming Exercises of Arrays, Lists, and Strings

Explore our set of Python Programming Exercises! Specifically designed for beginners, these exercises will help you develop a solid understanding of the basics of Python. From variables and data types to control structures and simple functions, each exercise is crafted to challenge you incrementally as you build confidence in coding in Python.

  •  Positive and Negative Number Array

    This Python program prompts the user to enter 10 real numbers and calculates two averages: one for the positive numbers and another for the negative numbers...

  •  Numerous Numbers and Their Sum

    This Python program prompts the user to enter several numbers, calculating their sum as they go. The program continues to prompt the user for numbers until they enter...

  •  Matrix Array

    This Python programming exercise is ideal for practicing the handling of multidimensional arrays. In this case, the goal is to prompt the user for the marks of 20 students, ...

  •  Advanced Statistics

    This Python statistical program is a fantastic exercise for improving data handling and user interaction in programming. The program allows users to add new data...

  •  Namedtuple

    This Python program is an excellent introduction to using NamedTuples for storing structured data. The program allows users to define 2D points with specific f...

  •  Array of Namedtuple

    In this exercise, you will develop a Python program that expands the previous exercise (NamedTuple point), allowing up to 1,000 points to be stored using an "array of...