Level 2

icon picker
Challenge 3

Aim:

Learn about dictionaries and how to use them in Python.

Task 1: Learning Dictionaries

Learning Objectives: PY02.5, PY07.2.1
Task
Complete the chapter on .
Complete sections 37-40 from this .
Read the following article about return: .
In particular, really focus on the use cases of when to use print vs when to use return

Task 2: HR Management System

Learning Objectives: PY02.5.1, PY02.5.3, PY02.5.4
In this task, we’re going to create a simple Human Resource management system for a company.
Here is the data you’ll be working with:
People Directory 2
0
First name
Last name
Age
Employed
1
Jane
Doe
42
2
Tom
Smith
18
3
Mariam
Coulter
66
4
Gregory
Tims
8
There are no rows in this table
Task
Create a new Repl on Repl.it named “L2 Challenge 3: Task 2”
Convert the below data into Python dictionaries.
You should add all of your dictionaries to a list called people
When you’ve added their data to a list of dictionaries complete the following tasks:
2. Iterate over the array of people and for each print their details to the console in a human readable way. For example:
Name: Jane DoeAge: 42Employed: Yes
3. Next, add an input prompt that will ask the user for what action they want to do
The input will accept two answers “Add” or “Remove
4. If the user types “Add”, show inputs in the console in a row that will ask the user for their Name, Age and if they are Employed or not.
Create a new dictionary with the properties entered
Add the new person to people list
Print the updated list of people to the console.
5. If the user types “Remove”, show an input in the console asking which user should be deleted.
If the user types the name of an existing person then that person should be removed from the “people” list
e.g. if the user types “Jane” then Jane Doe will be removed from the “people” array
Print the updated list of people to the console.
6. Finally, show the input prompt from Step 2 again.
Can you work out a way to always keep on asking the user for their next input after each Add or Remove flow has been completed?
Hint!
Consider using a while loop.

Task 3: Numbers to Dictionaries

Learning Objectives: PY07.1
Task
On Repl.it, create a new Repl called ‘L2 Challenge 3: Task 3’.
Complete the CodeWars problem: (n.b. Objects are called Dictionaries in Python)
When you’ve completed the CodeWars, copy and paste your solution into your Repl
Hint!
Character codes are the codes that define text characters on computers
e.g. the character ‘a’ is the number 66 and the letter ‘d’ is the number 69
You can find the full list of numbers
The function can help you convert one into the other

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.