General Instruction: Write a python program that declares and initializes a one-dimensional list named mylist. The eleme

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

General Instruction: Write a python program that declares and initializes a one-dimensional list named mylist. The eleme

Post by answerhappygod »

General Instruction Write A Python Program That Declares And Initializes A One Dimensional List Named Mylist The Eleme 1
General Instruction Write A Python Program That Declares And Initializes A One Dimensional List Named Mylist The Eleme 1 (106.02 KiB) Viewed 30 times
General Instruction Write A Python Program That Declares And Initializes A One Dimensional List Named Mylist The Eleme 2
General Instruction Write A Python Program That Declares And Initializes A One Dimensional List Named Mylist The Eleme 2 (98.97 KiB) Viewed 30 times
Paste the code and screenshot the outputs 1-6
Python language
General Instruction: Write a python program that declares and initializes a one-dimensional 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 [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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply