Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions

Question

What are the challenges associated with tunneling in urban areas?

Answered: 1 week ago

Question

What are the main differences between rigid and flexible pavements?

Answered: 1 week ago

Question

What is the purpose of a retaining wall, and how is it designed?

Answered: 1 week ago

Question

How do you determine the load-bearing capacity of a soil?

Answered: 1 week ago

Question

what is Edward Lemieux effect / Anomeric effect ?

Answered: 1 week ago

Question

10-9 How have social technologies changed e-commerce?

Answered: 1 week ago