5) b. Keyword Arguments Examples




You are an international assassin. To cover yourself you have to destroy every evidence after the job, but as usual, you must hurry. You managed to log in to your target computer. Write a program that removes every record from the database that can be connected to you, your employer and your partners. To do this you have to write a function, where you will have as parameters the database (list) and one name that needs to be deleted across the database. You can call this function 3 times. Be sure, that you can call the function independent of the order of the arguments.

Concept 1: To call a function in any order of arguments, you can use keyword arguments to call the function.

Concept 2: Another important concept to learn here is when you need to delete multiple elements from a list (or any other data structure). You never start deleting items while you’re iterating over the list because that will affect your remaining iterations. Instead, you make a note of the indexes and then delete them. Another thing to note is that you delete the indexes starting from the end of the list and work your way backwards.

1
2
3
4
5
Output:
The data: ['Eminescu is the employer', 'Peter is the killer', 'Boris is the partner']
Without Eminescu: ['Peter is the killer', 'Boris is the partner']
Without Rajesh: ['Boris is the partner']
Without Boris: []




You were asked by the United Space Federation to write a program that calculates the threat provided by each known alien species.You got a database with different species and their military force from 1 to 10.Write a program that orders the alien species into descending order to know which species must be focused. To save time use the python onboard sorted function.

test

1
Output:




You are going to go to an interview to apply for your dream job. The only problem is if you didn’t manage to get in, you will be kidnapped and released in the middle of a desert. Your job is to create a program that completes a string with the given parameters. Write a function that inserts your first and last name at the end of a text. Don’t forget, that the interviewers are such fanatics that if you don’t use keywords to make sure the parameters won’t be mixed up you will fail the test.

test

1
Output: