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.

Welcome 🤗! In the next ~4h we will cover:

Valiant Technology Ltd., CC BY-SA 3.0, via Wikimedia Commons Source

Valiant Technology Ltd., CC BY-SA 3.0, via Wikimedia Commons Source

Before we begin with the class:

Test

(25 min)

Accept the assignment

👉 Use Submission from the editor

Preparation review

E: Reading check

E: Arithmetics, expressions, strings, values and types

Let us check your understanding to find out other holes.

E: Variables and statements

E: Functions

Coding

Heads up - Update your template and uninstall pyright extension

I modified the template. To update it:

  1. Go to Extensions

  2. Uninstall Pyright

  3. Go to Source Control and pull the changes

  4. You will seetwo additional extensions recommended. If not, go to Extensions and look to recommended extensions and install them.

Live coding

E: Restaurant bill

(5-10 min)

Do you need support?

Answer the following in 📊 Live poll:

  1. Do you need more support for the exercises in the class than what the teacher (and TA) supports you?

    1. Yes, most of the time I need more support than I currently get.

    2. Sometimes — depends on the exercise.

    3. No, the current support is enough and/or I rarely need help.

    4. I don’t know.


  2. Do you have time and energy to support your fellows, including those sitting further from you?

    1. Yes, most of the time.

    2. Sometimes – depends on the exercise.

    3. No.

    4. I don’t know.


E: Restaurant bill

(5-10 min)

E: Center align

Write a function named center_align that takes a string named text as the first parameter and width as the second parameter and prints the string with enough leading spaces that the strings are centered int the middle of width number of columns.

def print_center_aligned(text, width):
    """ Aligns the string in the center of the `width` number of columns."""
    ## YOUR CODE HERE


print_center_aligned("geko", 20)
print_center_aligned("is", 20)
print_center_aligned("very happy today!", 20)


print_center_aligned("geko", 50)
print_center_aligned("is", 50)
print_center_aligned("very happy today!", 50)

The code should output:

        geko
         is
  very happy today!
                       geko
                        is
                 very happy today!

E: 99 Bottles of beer

(10-20 min) https://allendowney.github.io/ThinkPython/chap03.html#id3

E: Converting seconds to hours, minutes, and seconds

E: Budget variance

Turtle graphics

We will use Turtle 🐢 to learn algorithmic thinking.

E: Hello Turtle

E: Reflection

License unknown Source

License unknown Source

Footnotes