Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone do question 6-11 in Python? Task 1: list Basics For this task you will practice using list methods, indexing, and such. Use the

Can someone do question 6-11 in Python?image text in transcribedimage text in transcribed

Task 1: list Basics For this task you will practice using list methods, indexing, and such. Use the IDLE Shell window for this task. 1. Create the following list: primes-[7, 11, 3, 5, 2, 13, 4]. Use the pop ) method to remove the last element. Use help (list ) for information on ist methods. 2. Now use the insert method to add 17 just after 11 in primes. 3. Next use the sort ( method to sort primes, and finally use the reverse (method to obtain a list of the first 7 primes in reverse order. 4. Create two empty lists favel and fave2 5. Add 'Cougar sports' to one list and Facebook' to the other. 6. Now add 4 of your favorite things (foods, movies, music, groups, activities, colors, whatever) to each list. You might want to utilize the keyboard shortcut Alt-p (Windows) or Control- p (Mac OS X) to minimize the amount of typing you have to do. This allows you to rewrite commands on the current line and then edit them. 7. Combine favel with fave2 using the extend method, and check to see whether one list is twice as long as the other using the len () function. Note that the extend method is a void method, and the original favel is changed. 8. If one list is twice as long as the other, continue to the next step. If not, append () more items until you have ten items in one of the lists. 9. Rename the longer list to a list called top.ten. Sort this list, and make sure it's been sorted (by viewing it). 10. Now replace ' Cougar sports' and ' Facebook' (using the proper indexes-be care- ful!) so that top.ten is now reallya list of your favorites. If you delete one of your own items, add it back and try again. Sort your final list. 11. As mentioned previously, you can combine two lists using the void extend method, but this changes the list you extend. You can combine two lists very easily using using operator overloading. Create alist with the integers 1, 2, and 3. Now create blist with the integers 4, 5, and 6. Check to make sure alist and blist contain the correct integers. Now create clist by adding alist and blist together using operator overloading, i.e

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions