๐Ÿ’ป Week 01 Lab

Interactive Python Practice in Nuvolos

Author
Published

21 January 2025

๐Ÿฅ… Learning Goals
By the end of this lab, you should be able to: i) Understand the structure of a Python interactive development environment; ii) Execute Python code using Jupyter Notebooks; iii) Use variables, data types, and basic operations in Python; iv) Use the print() function to display and format output.
Image representing data transformation and discovery themes.

Last Updated: 21 January 2025, 18:30 GMT

๐Ÿ“Time and Location: Friday, 24 January 2025 at KSW.2.10. Check your timetable for the precise time of your class.

๐Ÿ“‹ Preparation

Before your first lab session, choose one of the options below to set up your Python environment on Nuvolos or locally (if youโ€™re feeling particularly brave).

Run On Your Own Laptop (ONLY FOR THE BRAVEST STUDENTS โ€“ NOT RECOMMENDED)

โš ๏ธ WARNING: Setting up a local environment isnโ€™t straightforward. Unlike the apps you install from the App Store, coding setups can throw unexpected errors that even instructors might struggle to debug. We highly recommend using Nuvolos at the start of the course. Weโ€™ll help you set up your laptop later with more time.

Choose this path only if you feel fully confident in your ability to install software and resolve potential issues independently.

Steps for Local Setup:

  1. Download and install Anaconda for your operating system (you can skip the registration part). Let it install everything it wants to install.

  2. Download and install VS Code. This should be more straightforward.

  3. Create a dedicated folder on your computer โ€“ NOT on your desktop โ€“ for this course. Call it DS105W or something similar.

  4. Under this folder, create a new folder called Week 01 - Python Basics.

  5. Download the lab notebook and place it inside the Week 01 - Python Basics folder.

  6. Open VS Code, then go to File > Open Folder and select the DS105W folder you created.

    You should see the following structure:

    DS105W/
    โ”œโ”€โ”€ Week 01 - Python Basics/
    โ”‚   โ””โ”€โ”€ W01 Lab - Python Basics.ipynb
  7. Open the notebook by double-clicking on W01 Lab - Python Basics.ipynb.

Youโ€™re all set! Letโ€™s get started with the lab.

๐Ÿ›ฃ๏ธ Lab Roadmap

Part I: Welcome, Setup, and Python Basics (20 min)

Note to class teachers: Begin by introducing yourself and outlining the session objectives. Guide students through the setup process on Nuvolos or assist those troubleshooting local installations. Once everyone is set up, proceed with a hands-on introduction to Jupyter Notebooks.

๐Ÿง‘๐Ÿปโ€๐Ÿซ TEACHING MOMENT

Give your full attention to your class teacher! They will guide you through the initial tasks on Part I of the notebook.

At the end, you should be able to use the skills you learned during the DataQuest lessons from the ๐Ÿ“ W01 Formative Exercise and accomplish the following tasks:

  • Input and print Londonโ€™s current temperature (london_current_temp).
  • Write an if/else statement to compare against a personal cold_threshold variable.

Part II: Working with Lists (30 min)

Note to class teachers: Encourage students to work independently on this section. Circulate the room, offering assistance as needed. Suggest they collaborate and support each other if stuck. At the end of the allocated time, gather their attention for a live solution walkthrough.

๐ŸŽฏ ACTION POINTS

Using Part II of the notebook, complete the following:

  • Create lists for:
    • Daily maximum temperatures (london_forecast_max).
    • Daily minimum temperatures (london_forecast_min).
    • Daily weather conditions (london_forecast_conditions).
  • Write code to:
    • Access specific elements, such as todayโ€™s and tomorrowโ€™s weather.
    • Format and print a simple two-day forecast, including max and min temperatures and conditions.

๐Ÿง‘๐Ÿปโ€๐Ÿซ TEACHING MOMENT

At the end of this section, your class teacher will:

  • Live-code the solution on screen.
  • Explain any advanced concepts, like indexing or list slicing, used in their solution.
  • Share their final notebook version on Slack for reference.

Part III: Day-by-Day and Weekly Summary (40 min)

Note to class teachers: Encourage students to work independently or in small groups. Toward the end of the session, gather everyone for a live walkthrough of a solution. You can either stick to the weekโ€™s core practices or introduce more advanced techniques (e.g., loops, f-strings) based on the classโ€™s progress and engagement. Adapt your approach as needed to match the roomโ€™s energy and understanding.

๐ŸŽฏ ACTION POINTS

Complete the tasks in Part III of the notebook:

  • Write code to display:
    • A day-by-day summary showing the day of the week, min and max temperatures, and weather condition.
    • Use an asterisk (*) to mark days where the max temperature is below your cold_threshold.
  • Write a weekly summary showing:
    • Average high and low temperatures.
    • The temperature range for the week.

๐Ÿง‘๐Ÿปโ€๐Ÿซ TEACHING MOMENT

During the final demonstration, your class teacher may:

  • Highlight techniques for improving efficiency, such as for loops.
  • Show you the power of special characters like \t and \n for formatting output.
  • Give you tips on how to format strings dynamically with f-strings.
  • Explain the importance of clean and readable code.

๐Ÿก Take-Home Exercise: Multi-City Analysis

This weekโ€™s take-home exercise will extend your learning by comparing Londonโ€™s forecast with another cityโ€™s forecast.

๐Ÿ’ก TIP: This activity will help you practice the skills you learned in the lab and reinforce your understanding of Python basics and it will be the starting point for the ๐Ÿ“ W02 Formative Exercise 1.

๐ŸŽฏ ACTION POINTS

Extend your learning by completing the optional take-home exercise in Part IV of the notebook, which includes the following tasks:

  • Create lists for another cityโ€™s forecast (e.g., Paris):
    • Max and min temperatures.
    • Weather conditions.
  • Compare London and the other city:
    • Format a side-by-side daily forecast for both cities.
    • Write a weekly summary for each city.

Footnotes

  1. link not yet availableโ†ฉ๏ธŽ