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.

Main block (`if __name__ == "main"`)

Programming task — enter your code and have it checked. Follow the pattern throughout: Function above define, in block if __name__ == "__main__": the function call and the result output. For most parts you read the values input() and the check compares your output character by character — enter there only what is required. For two parts (4 and 6) you set the values against them yourself in the main block; There we check the behavior of your function directly.

Part 1 — Direct execution and import

Use an existing function and control when the program starts.

Exercise

In the functions module, you wrote hallo(name) yourself. Here, the function is already provided. Your new task is to distinguish direct execution from import.

  1. Keep the provided function above the main block.
  2. Below it, add if __name__ == "__main__":Read a name only inside this block using input() and output the return value of hallo(name) out.
  3. When run directly, the program should output, for example, Hallo, Max! When imported, the program must not request input or produce output; the function must still be callable.

“Run” executes your program directly. “Check” also tests importing it under a different module name.

Part 1 — Your Code

Loading Python…
Output

    

Part 2 — Function addiere(a, b)

Read in two numbers, add them, output them.

Exercise

  1. Write a function addiere(a, b), which returns the sum of the two parameters.
  2. In the main block: read two in a row integers a and b one - each with int(input()).
  3. Call the function and return only the sum.

In the inputs 2 and 3 appears 5.

Part 2 — Your Code

Loading Python…
Output

    

Part 3 — Function zeige_name(name)

Incorporate the read name into a sentence.

Exercise

  1. Write a function zeige_name(name), which contains a sentence with the passed name return.
  2. In the main block: read a name input() there.
  3. Call the function and print the result.

Be specific Der Name ist <name>. off — when entering Lena therefore Der Name ist Lena.

Part 3 — Your Code

Loading Python…
Output

    

Part 4 — plus_eins(x) and minus_eins(x)

Define two functions - here you set the value yourself, none input().

Exercise

  1. Write two functions: plus_eins(x) gives it away one increased value back, minus_eins(x) the around one decreased.
  2. In the main block, set x yourself to a fixed value (no input()).
  3. Call both functions and give plus_eins(x) in Row 1 and minus_eins(x) in Row 2 out.

What counts here is not a fixed output, but rather that your functions for everyone Calculate value correctly: The test is calling plus_eins(...) and minus_eins(...) even with several numbers (e.g. B. expects them at 5 the values 6 and 4).

Part 4 — Your Code

Loading Python…
Output

    

Part 5 — begruessung(vorname, nachname)

Combine two entries into one sentence.

Exercise

  1. Write a function begruessung(vorname, nachname), which returns a completed greeting sentence.
  2. In the main block: read one after the other First name and Name one (two input()).
  3. Call the function and print the result.

Be specific Hallo, <vorname> <nachname>! from — at Mia and Schmidt therefore Hallo, Mia Schmidt!

Part 5 — Your Code

Loading Python…
Output

    

Part 6 — flaeche_und_umfang(breite, hoehe)

Two return values + tuple unpacking — you set values yourself, none input().

Exercise

  1. Write a function flaeche_und_umfang(breite, hoehe), the two values returns: first the area, then the perimeter. Separate both values in return with a comma — Python then packs them into a tuple.
  2. In the main block, set Width and Height yourself to fixed integers (no input()).
  3. Calls flaeche_und_umfang(...) up and catch them two Returns with tuple unpacking in two variables (two names separated by commas to the left of the =).
  4. Give that Area in line 1 and the Scope in line 2 out.

The returned tuple of your function is checked for several rectangles - the test calls flaeche_und_umfang(...) itself on (at 4 and 5 expects them (20, 18): area 20, scope 18). Pay particular attention to the scope: it counts every page with, i.e. twice the width plus twice the height.

Part 6 — Your Code

Loading Python…
Output

    

Report as PDF

Document and download your results.

Module overview

PartStatus
Part 1: Execution and importOpen
Part 2: addOpen
Part 3: show_nameOpen
Part 4: plus_one / minus_oneOpen
Part 5: greetingOpen
Part 6: area_and_perimeterOpen

Not all parts are completed yet - you can still create the report, which will then mark which parts are open.

Download PDF

Enter your name and download the report as a PDF.