4.2k views
20 votes
Create the logic for a program that prompts a user for 12 numbers and stores them in an array. Pass the array to a method that reverses the order of the numbers. Display the reversed numbers in the main program.

User Z Douglas
by
5.6k points

1 Answer

7 votes

Answer:

Step-by-step explanation:

The following program is written in Python. It first creates a method that reverses the array using the built in reverse function. Then it creates the array, creates a loop to ask the user to enter 12 numbers while passing each input into the array. Finally, it passes that array into the previously created reverse method and prints out the new array.

def reverse(num_arr):

num_arr.reverse()

return num_arr

num_arr = []

for x in range(12):

num = input("Enter a number")

num_arr.append(num)

print(reverse(num_arr))

User Ian Ringrose
by
4.8k points