General Instruction: Write a python program that declares and initializes a one-dmensional list named mylist. The elements in the mylist list are 5,10,15,20,25,30 and 35. The program will allow the user to choose 1-4, 1-to access an item in the list, 2- append the item in the list, 3- remove an item in the list by index, and 4-to change an item in the list by index. Detailed instructions are listed below: Use ladderized if elif else and for loop in this program. 1. Display first the following: (a) the elements in the list and (b) the operations to choose from.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 8PE
icon
Related questions
Question

In python program.

4. If the user chooses 2, the program will allow the user to enter a number to be added after
the last element in the list. Then the program will display the elements in the list after adding.
The Elements in the list are:
5 10 15 20 25 30 35
(1] Access item
[2] Add item
[3] Remove item by index
[4] Change item by index
Choose Operation:2
Enter number to add in the list:100
The Elements in the list after add are: 5 10 15 20 25 30 35 100
5. If the user chooses 3, the program will ask the user to enter the item index to remove from
the list. Then the program will display the element in that index before removing it. After
displaying the element to be removed, the program will display the elements in the list after
removal.
The Elements in the list are:
5 10 15 20 25 30 35
[1] Access item
[2] Add item
[3] Remove item by index
[4] Change item by index
Choose Operation:3
Enter item index to remove in the list:5
Element 30 was removed
The Elements in the list after removed are: 5 10 15 20 25 35
6. If the user chooses 4, the program will ask the user to enter the item index to modify in the
list. For example, the user entered index 2, the program will identify what element are residing
at index 2, then it displays the element. After displaying the element to be replaced, the program
will ask the user to enter a NEW number as the replacement. The program will display the final
elements in the list, and make sure the element to be replaced is already replaced by a new
number.
The Elements in the list are:
5 10 15 20 25 30 35
(1] Access item
(2] Add item
[3] Remove item by index
[4] Change item by index
Choose Operation:4
Enter item index to change in the list:2
Number to be replaced is: 15
Enter NEW number:200
The Elements in the list after replace are: 5 10 200 20 25 30 35
Transcribed Image Text:4. If the user chooses 2, the program will allow the user to enter a number to be added after the last element in the list. Then the program will display the elements in the list after adding. The Elements in the list are: 5 10 15 20 25 30 35 (1] Access item [2] Add item [3] Remove item by index [4] Change item by index Choose Operation:2 Enter number to add in the list:100 The Elements in the list after add are: 5 10 15 20 25 30 35 100 5. If the user chooses 3, the program will ask the user to enter the item index to remove from the list. Then the program will display the element in that index before removing it. After displaying the element to be removed, the program will display the elements in the list after removal. The Elements in the list are: 5 10 15 20 25 30 35 [1] Access item [2] Add item [3] Remove item by index [4] Change item by index Choose Operation:3 Enter item index to remove in the list:5 Element 30 was removed The Elements in the list after removed are: 5 10 15 20 25 35 6. If the user chooses 4, the program will ask the user to enter the item index to modify in the list. For example, the user entered index 2, the program will identify what element are residing at index 2, then it displays the element. After displaying the element to be replaced, the program will ask the user to enter a NEW number as the replacement. The program will display the final elements in the list, and make sure the element to be replaced is already replaced by a new number. The Elements in the list are: 5 10 15 20 25 30 35 (1] Access item (2] Add item [3] Remove item by index [4] Change item by index Choose Operation:4 Enter item index to change in the list:2 Number to be replaced is: 15 Enter NEW number:200 The Elements in the list after replace are: 5 10 200 20 25 30 35
General Instruction: Write a python program that declares and initializes a one-dmensional
list named mylist. The elements in the mylist list are 5,10,15,20,25,30 and 35. The
program will allow the user to choose 1-4, 1-to access an item in the list, 2- append the item in
the list, 3- remove an item in the list by index, and 4-to change an item in the list by index.
Detailed instructions are listed below:
Use ladderized if elif else and for loop in this program.
1. Display first the following: (a) the elements in the list and (b) the operations to choose from.
The Elements in the list are:
5 10 15 20 25 30 35
[1] Access item
[2] Add item
[3] Remove item by index
[4] Change item by index
Choose Operation:
2. If the user chooses 1, he will enter the index of the element and then the program will
display the element based on inputted index.
The Elements in the list are:
5 10 15 20 25 30 35
[1] Access item
[2] Add item
[3] Remove item by index
[4] Change item by index
Choose Operation:1
Enter index of element:3
Element at index 3 is 20
3. If the user, chooses an index beyond index 0-6, the program will display, "Invalid Index, please
choose between 0-6. This statement is shown in all operations from 1-4 if the user entered an
invalid number. The index number must be from 0-6 only.
The Elements in the list are:
5 10 15 20 25 30 35
[1] Access item
[2] Add item
[3] Remove item by index
[4] Change item by index
Choose Operation:1
Enter index of element:8
Invalid Index, please choose between 0-6
4. If the user chooses 2, the program will allow the user to enter a number to be added after
the last element in the list. Then the program will display the elements in the list after adding.
The Elements in the list are:
5 10 15 20 25 30 35
Transcribed Image Text:General Instruction: Write a python program that declares and initializes a one-dmensional list named mylist. The elements in the mylist list are 5,10,15,20,25,30 and 35. The program will allow the user to choose 1-4, 1-to access an item in the list, 2- append the item in the list, 3- remove an item in the list by index, and 4-to change an item in the list by index. Detailed instructions are listed below: Use ladderized if elif else and for loop in this program. 1. Display first the following: (a) the elements in the list and (b) the operations to choose from. The Elements in the list are: 5 10 15 20 25 30 35 [1] Access item [2] Add item [3] Remove item by index [4] Change item by index Choose Operation: 2. If the user chooses 1, he will enter the index of the element and then the program will display the element based on inputted index. The Elements in the list are: 5 10 15 20 25 30 35 [1] Access item [2] Add item [3] Remove item by index [4] Change item by index Choose Operation:1 Enter index of element:3 Element at index 3 is 20 3. If the user, chooses an index beyond index 0-6, the program will display, "Invalid Index, please choose between 0-6. This statement is shown in all operations from 1-4 if the user entered an invalid number. The index number must be from 0-6 only. The Elements in the list are: 5 10 15 20 25 30 35 [1] Access item [2] Add item [3] Remove item by index [4] Change item by index Choose Operation:1 Enter index of element:8 Invalid Index, please choose between 0-6 4. If the user chooses 2, the program will allow the user to enter a number to be added after the last element in the list. Then the program will display the elements in the list after adding. The Elements in the list are: 5 10 15 20 25 30 35
Expert Solution
steps

Step by step

Solved in 3 steps with 7 images

Blurred answer
Knowledge Booster
Stack
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning