credit: author: @RobDWaller
There are four tasks to complete based around a list of dictionaries which represent pseudo-data for website URLs. Each task aims to test a developer's ability to manipulate and edit a list of data.
The data can be found in the /websites/resouces/data.py file.
The data can be viewed by running the following commands on the command line in Python's interactive mode:
python
>>> from websites.resources.data import WEBSITES
>>> print(WEBSITES)The data structure is as follows, with five keys for each item:
[
{
"name": "Google",
"url": "https://www.google.co.uk",
"domain": "google.co.uk",
"secure": True,
"value": 5
},
{
"name": "Facebook",
"url": "https://developers.facebook.com/blog/post/2018/10/02/facebook-login-update/",
"domain": "facebook.com",
"secure": True,
"value": 4
}
]To complete the assessment please clone the repository.
Write your code to complete the tasks and then store your code in a public git repository on GitHub or equivalent service. Alternatively zip the code up and submit via email.
You should not spend more than one hour completing this assessment. You will not be judged based on how many questions you answer but how well you answer each question.
Find and return a new list of data where each item's value key is equal to or greater than four.
Example: The below dictionary should be one of the items returned in the new list.
{
"name": "Facebook",
"url": "https://developers.facebook.com/blog/post/2018/10/02/facebook-login-update/",
"domain": "facebook.com",
"secure": True,
"value": 4
}Amend the list so each domain key value is prepended with the string www.
Example: An amended dictionary should look as below where facebook.com has become www.facebook.com.
{
"name": "Facebook",
"url": "https://developers.facebook.com/blog/post/2018/10/02/facebook-login-update/",
"domain": "www.facebook.com",
"secure": True,
"value": 4
}Some of the data is inaccurate, the secure key is set to False when the url key contains a URL beginning with https://. The opposite is also true in some cases.
The list should be cleansed and returned so the secure keys are accurate.
Example: The below dictionary should be amended to look as follows. It's current state is secure equals False even though the url key contains https://.
{
"name": "Bing",
"url": "https://www.bing.com/search?q=athlete&qs=n&form=QBLH&sp=-1&pq=athlete&sc=8-7&sk=&cvid=53830DD7FB2E47B7A5D9CF27F106BC9A",
"domain": "bing.com",
"secure": True,
"value": 3
}Add up all the value keys in the list and return an integer.
Example: If we added up the below value keys we'd get an integer of 9, 5 + 4.
[
{
"name": "Google",
"url": "https://www.google.co.uk",
"domain": "google.co.uk",
"secure": True,
"value": 5
},
{
"name": "Facebook",
"url": "https://developers.facebook.com/blog/post/2018/10/02/facebook-login-update/",
"domain": "facebook.com",
"secure": True,
"value": 4
}
]