subject
Engineering, 22.02.2020 00:58 yoyo2697

The main() module in the starter code below takes integar inputs separated by commas from the user and stores them in a list. Then, it allows the user to manipulate the list using 3 functions:

mutate_list() takes 3 parameters -- a list, index number, and a value -- and inserts the value in the position specified by the index number in the list.

remove_index() takes 2 parameters -- a list and an index number -- and remove the element at the position number indicated by index. It also prints the total number of elements in the list before and after removing the character in this fashion:"Total elements in list = 11
Total elements in list = 10"

reverse_list() takes 1 parameter -- a list -- and returns the list reversed.

Examples:

Example 1:

Enter values in list separated by commas: 1,2,4,63,6,4,22,53,76
[1, 2, 4, 63, 6, 4, 22, 53, 76]
Menu:
mutate list(m), remove (r), reverse_list (R)

Enter choice (m, r,R): m

4,45
[1, 2, 4, 63, 45, 6, 4, 22, 53, 76]

Example 2:

Enter values in list separated by commas: 1,2,4,6,84,3,2,2,76
[1, 2, 4, 6, 84, 3, 2, 2, 76]
Menu:
mutate list(m), remove (r), reverse_list (R)

Enter choice (m, r,R): R
[76, 2, 2, 3, 84, 6, 4, 2, 1]

Example 3:

Enter values in list separated by commas: 12,2,3,5,2,6,2,1,2,333,65
[12, 2, 3, 5, 2, 6, 2, 1, 2, 333, 65]
Menu:
mutate list(m), remove (r), reverse_list (R)

Enter choice (m, r,R): r

Example 4
Total elements in list = 11
Total elements in list = 10
[12, 2, 3, 5, 6, 2, 1, 2, 333, 65]

please use the codes below

def main():
user_list = input("Enter values in list separated by commas: ")
user_list = user_list. split(",")
user_list = [int(i) for i in user_list]
print(user_list)
print("Menu: ")
print("mutate list(m), remove (r), reverse_list (R)")
user_choice = input("Enter choice (m, r,R): ")
if user_choice == 'm':
index_num, v = input().split(",")
index_num = int(index_num)
v = int(v)
mutate_list(user_list, index_num, v)
print(user_list)
elif user_choice == 'r':
index_num = int(input())
remove_index(user_list, index_num)
print(user_list)
elif user_choice == 'R':
new_list = reverse_list(user_list)
print(new_list)
main()

ansver
Answers: 1

Another question on Engineering

question
Engineering, 04.07.2019 19:20
Air at a pressure of 1atm and a temperature of 40 c is in parallel flow over the top surface of a flat plate that is heated to a uniform temperature of 120 c. the plate has a length of 0.40m (in the flow direction) and a width of 0.15m. the reynolds number based on the plate length is 50, 000. what is the rate of heat transfer from the plate to the air? if the free stream velocity of the air is doubled and the pressure is increased to 10 atm what is the rate of heat transfer?
Answers: 2
question
Engineering, 05.07.2019 23:20
Which one of the following faults cause the coffee in a brewer to keep boiling after the brewing cycle is finished? a. an open circuit in the heating element b. a short circuit at the terminals c. welded contacts on the thermostat d. a leak around the gasket
Answers: 3
question
Engineering, 06.07.2019 04:30
Calculate the equilibrium concentration of vacancies per cubic meter in pure aluminum at 500°c. assume that the energy of formation of a vacancy in pure aluminum is 0.76 ev. what is the vacancy fraction at 650°c.
Answers: 3
question
Engineering, 06.07.2019 05:10
Determine the heat loss per hour from a wall of a build- ing when the wind is blowing parallel to its surface with a speed of 2 km/hour. the wall is 5 metre long and 3 metre high. tempe rature of the wall is 25°c and air temperature is 5°c.
Answers: 2
You know the right answer?
The main() module in the starter code below takes integar inputs separated by commas from the user a...
Questions
question
Geography, 26.10.2019 07:43
question
English, 26.10.2019 07:43
Questions on the website: 13722360