Question: Use Python to solve the questions below: Task 1 Build a list with the following contents: [1, 2, 3, 4, 5, 6, 7, 8,

Use Python to solve the questions below:

 Task 1 

• Build a list with the following contents: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] • Print out the following subsets of that list: ◦ 1 to 6 ◦ 3 to 7 ◦ Even numbers ◦ 9 to 5 (in reverse order) 

 Task 2 

• Using the same list from Task 1, do the following ◦ Change the first element to 1.5 ◦ Add a new element 8.5 to the end of the list ◦ Insert the value 5.5 in between the existing elements 5 and 6 in the list ◦ Remove the existing element 10 ◦ The list is now out-of-order, so sort it!

 Task 3 

• Ask the user to input a string • Build a new string variable, containing only the vowels and spaces from the user's string • Build another new string variable, with the ps and qs removed from the user's string • Hint: This shouldn't require more than 10-15 lines of code 

 Task 4

 • Build 4 lists (e.g., e1, e2, ...) of the below form, to store employee information. 

Use whatever values you want, as long as they match the below structure.

  ["John Doe", 30, "Mechanic", "Part-time", "ON"]

 ["Jane Dee", 33, "Builder", "Full-time", "BC"] 

["name", age, "job_title", "contract_type", "location"] (general structure) 

 

• Add these 4 lists to another list (e.g., employees); we now will have a 2-dimensional list 

 • Write a function called check_employee_exists(name), which will check whether our 2d list contains any employee which matches the given name. 

◦ If the employee exists, the function should return True. Otherwise, it should return False. 

 • Write another function called add_employee(), which will prompt the user for the details of a new employee, then add that new employee to the employees 

◦ This function should check that the user enters valid input, as follows: 

▪ name and job_title should both be strings. The function should capitalize each word in these strings, in case the user hasn't already done so.

▪ age should be an integer, between 15 and 150 

▪ contract_type should be a string, either "Full-time" or "Part-time". 

▪ location should be a two-character string. You don't need to check if the location exists. 

• Note: for both of these functions, the employees list is not passed as an argument, and the functions do not return a new list. employees is a global variable, so we can access it anyway

Step by Step Solution

3.49 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

I have written down the Python codes for each task using the given condition Task 1 Here is the Pyth... View full answer

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 Programming Questions!