Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use python to solve the questions below: Task 1 Create a list with the following contents: [1, 2, 3, 4, 5, 6, 7, 8, 9,

Use python to solve the questions below:

Task 1

Create 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 Create a new string variable, containing only the vowels and spaces from the user's string Create 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

Create 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 employees

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

name and job_title should both be strings. The function should capitalise 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

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

Describe how data could be transmitted using frequency modulation.

Answered: 1 week ago