βœ… Week 01 Lab Solutions

Author
Published

27 January 2025

Image representing data transformation and discovery themes.

Last Updated: 27 January 2025

Parts I, II, and III of the πŸ’» W01 Lab were designed so that you would attempt them by using the knowledge you got from the DataQuest lessons we asked you to take last week plus new concepts that were introduced in class by your class teacher. I gave them the freedom to choose how they want to go about the solutions, according to the dynamics of the classroom and here I bring together some of their solutions as well as my own step-by-step guide to think about the Take-Home exercise based on Riya’s solution to her class group.

πŸ“₯ Download Solutions

Class teachers Riya and Barry have shared their own versions of the full notebook with the lab solutions. As there are always multiple ways to solve a problem, it might be worth conmparing your solution with theirs.

You can download the notebooks below:

Stuart also wrote a message and shared it on the #class-group-4 channel:

Click to read Stuart’s message

As promised, here is how you can answer part 3.1 using a for loop. You should be able to replicate this code chunk as is. In particular, check out how i substitutes for the 1st, 2nd and 3rd element in each list. As mentioned, I renamed all the lists inside the for loop as typing them inside the f-string makes it overly long.

cold_threshold = 9
london_forecast_max = [8,8,10]
london_forecast_min = [1,0,3]
london_forecast_conditions = ["🌧️","🌧️","☁️"]
date = ["Wed, 22 Jan 2025","Thu, 23 Jan 2025","Fri, 24 Jan 2025"]

print("FORECAST\n=========================================\n")
for i in range(0,3):

    # Parameters
    dates = date
    emojis = london_forecast_conditions
    mins = london_forecast_min
    maxes = london_forecast_max

    # String concatenation
    london_forecast_summary = f"{dates[i]} - {emojis[i]} Min: {mins[i]}Β°C, Max: {maxes[i]}Β°C"

    # If-Else statement
    if london_forecast_max[i] < cold_threshold:
        print(f"{london_forecast_summary}*")
    else:
        print(london_forecast_summary)
print("...")

See you next Friday, Stuart

πŸ“ Take-Home Exercise

The solution to the Take-Home Exercise was embedded into the πŸ“ W02 Formative Exercise. Take a look at the solution over there and don’t forget to take the listed DataQuest lessons!