Student Performance Prediction · Project

Student Performance Prediction · Foundation · Path B

Python Essentials in a Notebook

Run Python in Google Colab and learn the variables, lists, dictionaries, loops and functions used throughout the student performance project.

What you need

A computer with a web browser and a free Google account for Google Colab, or Python with Jupyter installed locally. Libraries: pandas, scikit-learn and matplotlib (all free).

In this lesson you will

  • Run and edit code cells in a notebook
  • Use variables, lists, dictionaries, loops and functions

Key concepts

notebookcode cellvariablelistdictionaryfunction

The lesson

A notebook mixes code cells and text cells. Run a cell with Shift+Enter; its output appears below. Variables created in one cell can be used in later cells, so run cells in order.

You will use lists to hold collections of values, dictionaries to hold named values (such as a model's scores), loops to repeat work, and functions to avoid repeating code.

Errors are normal. Read the last line of the error message first: it usually names the problem, such as a misspelt variable.

Step by step

  1. Open Google Colab and create a new notebook.
  2. Create variables for three students' scores and print their average.
  3. Store the scores in a list and a dictionary and loop over them.
  4. Write a function that returns 'support' if a score is below 50.

Practice activity

Complete a notebook of ten short exercises on variables, lists, dictionaries, loops and functions, using student-style examples.

Expected result: A notebook where every cell runs from top to bottom without errors.

Common mistakes

  • Running cells out of order and getting confusing errors
  • Copying code without reading what each line does

Check your understanding

  1. What happens if you run cells out of order?

    Show answer

    Variables may be missing or out of date, causing errors or wrong results.

  2. Which part of an error message should you read first?

    Show answer

    The last line, which usually names the problem.

Further learning

Projects are instructor-guided: an instructor sets milestones, checks your work and gives feedback, online or in person. Self-study of the public lessons does not lead to a certificate. Enrolment and fees follow the Academy's existing policies — contact the Academy.