Objective
Develop a Python program to prompt the user for 5 numbers, store them in an array, and display them in reverse order.
Example Python Exercise
Show Python Code
# Initialize an empty list to store the numbers
numbers = []
# Prompt the user for 5 numbers and store them in the list
for i in range(5):
number = float(input(f"Enter number {i+1}: "))
numbers.append(number)
# Display the numbers in reverse order
print("Numbers in reverse order:")
for num in reversed(numbers):
print(num)
Output
Enter number 1: 10
Enter number 2: 20
Enter number 3: 30
Enter number 4: 40
Enter number 5: 50
Numbers in reverse order:
50.0
40.0
30.0
20.0
10.0
Share this Python Exercise