Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Spiral Staircase in Vatican Museum Source
© User:Colin / Wikimedia Commons CC BY-SA 3.0

Spiral Staircase in Vatican Museum Source © User:Colin / Wikimedia Commons CC BY-SA 3.0

Before we begin with the class:

Test

(15 min)

Accept the assignment

Flowchart analysis

Learning goals

Compare flowchart with the text description and check correctness

E: Checking correctness

Peer feedback

Learning goals
  • Give feedback based on criteria.

  • Use a GitHub pull request to give feedback.

Giving feedback

Feedback can be formulated easier, if it is based on criteria. Criteria can in return improve how you do a task.

Here is an example, how we can give feedback for Exercise 3:

Example exercise

Input age, then name and store age and name in a database. If the user wants to enter more input, repeat the process.

Example criteria with feedback

Criteria

Comments

Has a start and end

end is missing

Used correct shapes

ok!

Fits description

Age input must come first, more input condition missing

Overall

You have the basics! Try to read the description again after you have drawn the flowchart.

E: Peer feedback using GitHub

Larger picture

We will use Feedback in Pull requests for giving feedback to each other. The feedback pull request presents all the changes the user has done.

Tracking changes is a superpower of repositories.

Core programming concepts

Learning goals
  • Recognize sequence, selection, iteration in processes

  • Find examples of sequence, selection and iteration

  • Differentiate between control and data

  • Recognize condition in selections

E: Matching the three concepts

The Big 3

We can describe any process using the following 3 structures.

Structure

Example

Code

Sequence

altitude-check-sequence.py
1
2
altitude = int(input())
print(altitude)

Selection

altitude-check-selection.py
3
4
5
6
if altitude > 100:
    print("Circling")
else:
    print("Landing")

Iteration[1]

altitude-check-iteration.py
3
4
5
6
7
while altitude > 0:
    print("Landing\n")
    altitude = int(input())

print("Landed")

Control vs data

In programming, we distinguish between:

Example: In the altitude example, we have:

  • control:

    • sequence of output, input

    • iteration as long as altitude > 0

  • data:

    • altitude

    • the messages “Landing” and “Landed”

E: Control vs data

Selection vs condition

Condition can be for example:

  • a == b

    • Is a equal to b? Pay attention to double equal sign.

  • a != b

    • Is a different from b?

  • a > b, a <= b etc

    • you already know from math.

E: Selection vs condition

Coding the process

Now use the previous Big 3 table to code the following examples.

E: Area of a square

E: Energy level manager

E: Counting laps

Code runner

You find the editor on website’s menu on the left: ▶️ Code runner.

E: VSCodium installation support

Next time we will use VSCodium to code.

Running a flowchart

Drawing flowcharts is already programming! See Running flowcharts, however flowcharts are often not enough to implement processes in detail compared to programming languages.

E: Reflection

Can you spot this variable? 👀

Can you spot this variable? 👀

Footnotes
  1. There are other ways to iterate, e.g., do-while or for. We leave them out for now for simplicity.

  2. If you are experienced with coding, then you will say that this problem is better solved with a for iteration. For the sake of slow ramp up for beginners, we use currently only while for iterations.