Question: Exercise-1: Make a list that includes four careers, such as 'programmer', 'truck driver', etc Use the list.index() function to find the index of a career

Exercise-1: Make a list that includes four careers, such as 'programmer', 'truck driver', etc Use the list.index() function to find the index of a career in your list. Use the in function to show that this career is in your list. Use the append() function to add a new career to your list. Use the insert() function to add a new career at the beginning of the list. Use a loop to show all the careers in your list.

Exercise-2: Write a function called is_sorted that takes a list as a parameter and returns True if the list is sorted in ascending order and False otherwise. You can assume (as a precondition) that the elements of the list can be compared with the relational operators <, >, etc. For example, is_sorted([1,2,2]) should return True and is_sorted(['b','a']) should return False.

Exercise-3: Write a function called remove_duplicates that takes a list and returns a new list with only the unique elements from the original. Hint: they dont have to be in the same order.

Exercise-4: Make a list of the first ten multiples of ten (10, 20, 30... 90, 100). There are a number of ways to do this, but try to do it using a list comprehension. Print out your list.

Exercise 5: Write a function called Chop that takes a list and returns a new list that contains all but the first and last elements. Name: Chop Argument: List Return: List

Here is an example of how to use (or test) the function: a = [a,b,c,d,e] b = Chop(a) print b # prints [b,c,d]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!