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.

GitHub Education Benefits Application

(10m)

Reading - input, extra print features and f-strings

(1h)

Reading PDF

Concepts:

  • input()

    • Reading an integer, floating point number and string

  • extra print features

    • end=

    • sep= for arguments

    • \n, \t, \"

  • f-strings

    • also see Print debugging

    • Placeholder expressions, f"{a+b}"

    • Formatting values, .e.g., {n:.2f}, {n:%}, {n:,}

    • Min field width, {n"12,.2f"}

    • Aligning values, {n:>10}, {n:^10}, etc

  • Named constants

    • magic numbers

    • UPPER_CASE

Reading - Decision structures and Boolean Logic

(3h) Reading PDF.

Until p.196, including Algorithm Workbench.

Concepts:

  • 1. if statement

    • control structure (remember #big3)

    • sequence structure

    • decision (selection) structure

    • single alternative decision structure

    • Boolean expressions and relational operators

      • >, <, >=, <=, ==, !=

    • Single line if: if cond: statement

  • 2. if-else

    • effect of indendation

  • 3. comparing strings

    • ==, !=

    • >, etc, for alphabetical sort

  • 4. nested decision structures, if-elif-else statement

    • instead of if-else-if-else...

  • 5. logical operators

    • and, or, not

    • short-circuit evaluation (for saving time)

  • 6. Boolean variables

    • used as flags: does a specific condition exist?

    • bool

  • 7. Conditional expressions

    • variable = value1 if condition else value2

  • 8. assignment expressions and walrus operator :=

  • 9. Turtle: determining the state

    • xcor(), ycor().

    • heading()

    • isdown()

    • isvisible()

    • pencolor()

    • fillcolor()

    • bgcolor()

    • pensize()

    • hit the target game

Reading - Repetition structures

(3h)

Reading PDF

Until p.255, including Algorithm Workbench.

Concepts:

  • 1. Introduction

    • Disadvantages of duplicated code

    • Condition- vs count-controlled loops

  • 2. while condition-controlled loop

    • syntax

    • while is a pretest loop

    • infinite loops

    • while as a count-controlled loop

    • single-line while loops

  • 3. for count-controlled loop

    • syntax, for n in [1, 2, 3]: print(n) (lists introduced later)

    • range function

    • using the target variable inside the loop, e.g., squaring the number

    • letting the user control the number of iterations (range(n))

    • Generating a descending sequence (range(10, 1, -1))

  • 4. Calculating a running total

    • total = total + n

    • Augmented assignment operators: +=, -=, *=, /=, %=, //=, **=

  • 5. sentinels

  • 6. Input validation loops

    • while input_not_correct: prompt_user()

    • using the Walrus :=: while (inp := input()) != "y"

  • 7. Nested loops

    • e.g., for row in range(10): for col in range(10) : f()

  • 8. Using break, continue, and else with loops

    • should be used with great caution — make the code less readable

    • while cond: f(); else: g()

  • 9. Turtle: Using loops to draw designs

We meet in X2.38 again (instead of Robotlab)

I modified Semester schedule 📆