Save / load workspace

Save your lab results on this server for 48 hours. Use the token to continue on another device. Anyone who knows the token can open your workspace.

Save workspace

A name is required when you first save and is then permanently bound to this workspace. Task values, entries and progress are saved together.

Load workspace

New workspace

Start with empty results and a name of your choice. Previously saved tokens remain valid until they expire. Unsaved changes in this tab will be discarded.

Saving also transfers any included measurement files and analysis videos to this server. Running simulations are saved as a set of results and displayed in a paused state when loaded.

Module 1 — What is a dict?

A memory that stores values over a Key reinvented.

Definition

A Dictionary (short dict) is a collection of Key value pairs. Instead of using an index like with lists, you access a value via its Key to — usually a string.

Syntax:

name_des_dicts = {
    "schluessel1": wert1,
    "schluessel2": wert2,
}

An empty dictionary is created {}. In modern Python (from 3.7) the order remains the key obtained — it corresponds to the order when creating or adding.

Note on exercise: In the first four parts you set the dictionary values even in the code fixed - the focus is on creating, reading, replacing and adding to it. In part 5 and 6 you read the values input() on (from the module Variables known); There the check automatically feeds in fixed inputs and compares your output character by character.

Example 1.1 — create and output a dictionary

Loading Python…
Output

    

Module 2 — Reading and changing values

Key access — like a label on a drawer.

Read a value

With d["schluessel"] you get the saved value back. If the key doesn't exist, there is one KeyError.

Example 2.1 — read out individual values

Loading Python…
Output

    

Overwrite an existing value

If you write to an existing key, the old value becomes replaced. The syntax is exactly the same as reading — just on the left side of one =.

Example 2.2 — Change value

Loading Python…
Output

    

Module 3 — New keys and conditions

Dictionaries simply grow with you.

Create a new key

You write on one not yet existing key, it is added. This is the same command as overwrite.

Example 3.1 — Add key

Loading Python…
Output

    

Values with if check

You can use a dictionary value like any other variable in a condition: if d["preis"] > 10:. This allows small rules to be formulated based on stored values.

This one is enough here if-Query as Pre-taste — conditions with if, elif and else you'll learn in the next module (if, elif, else) know in detail.

Example 3.2 — Check value with if

Loading Python…
Output

    

Module 4 — Calculating with values

The stored values are normal numbers or strings.

Example: Average of two grades

If the values are numbers, you can calculate with them as usual. Just get involved d["schluessel"] to and use the result in an expression.

durchschnitt = (d["note1"] + d["note2"]) / 2

Example 4.1 — Average of Dictionary Values

Loading Python…
Output

    

TipKeys are strings

Write keys in quotation marks: d["alter"], not d[alter]. Without quotes, Python would search for a Variables search with this name - and this almost always throws an error.

Sources & further literature

Where the knowledge imparted here is officially documented.

Official Python documentation

Tutorials & Manuals

  • Real Python — Dictionaries in Python: realpython.com/python-dicts
  • Theis, Thomas: Getting started with Python. 7. Edition, Rheinwerk Verlag, 2023 — Chapter on dictionaries.
  • Klein, Bernd: Introduction to Python 3. 4. Edition, Hanser Verlag, 2021 — “Dictionaries” section.