Meetings 24FA

Fall 2024 class meetings are 1:30-2:35 on Monday, Wednesday, and Friday in SB 382. Labs are on Thursday, 12:15-1:55pm in SB 354 (the “Gold” lab).

Note that we count the week of Advising as “Week 7.5”.

Assignments

A summary of the assignments you completed this semester:

Homework

Homework due dates alternate with Forum due dates.

Optional Practice Exercises

  1. Leibniz formula (W5)

Labs

Forums

Week 1

Wednesday

Thursday

Checklist before you leave:

You might want to start on the homework too! Hints:

  1. Start with something you know works… like your star.
  2. pen.penup()
  3. You don’t have to use forward() and right(); you can also use pen.goto()

Friday

Logistics

Week 2

Monday

Wednesday

Friday

Week 3

Monday

Wednesday

Thursday

Friday

Week 4

Monday

Wednesday

Thursday

Friday

Week 5: Looping

Monday

Wednesday

Thursday

Lab 5

optional labs:

Friday

Week 6: Functions

Monday

Wednesday

Reference Turtle code for 5-pointed star:

import turtle
screen = turtle.Screen()
pen = turtle.Turtle()

for i in range(5):
    pen.forward(100)
    pen.right(144)
screen.mainloop()

Thursday

Lab 6

If you finish early, either do the optional labs from last week, or try making a Turtle click handler:

screen = turtle.Screen()
pen = turtle.Turtle()
pen.speed('fastest')

# whenever screen gets clicked, make the turtle go to that place
def handle_click(x, y):
    print(x, y)
    # TODO    

screen.onclick(handle_click)
screen.mainloop()

Extensions:

  1. Make two turtles that move in mirror image to each other.
  2. Extend the checkerboard lab so that the user can click on a square to change its color.

Friday

Week 7: Sequence Data

Monday

Wednesday

Thursday

Lab 7

Friday

Fall break.

Week 7.5

Monday

Fall break.

Wednesday

Advising break.

Thursday

Lab 7B

Friday

Week 8: Object-Oriented Programming (Classes)

Monday

Wednesday

Thursday

Lab 8

Friday

Week 9: Python for Data Science 1

Monday

Wednesday

Thursday

Lab 9

Friday

Week 10: Python for Data Science 2

Monday

Wednesday

Thursday

Lab 10

Friday

Week 11: Nested Structures

Monday

Examples:

Wednesday

Thursday

Lab 11: Image Processing

Friday

Google Quick-Draw dataset: download a file from here and save it in the same directory as a Python script with the following code:

import json
import numpy as np
import turtle
pen = turtle.Turtle()

filename = "YOUR_FILENAME_HERE.ndjson"
data = []
with open(filename) as f:
    for line in f:
        data.append(json.loads(line))
        if len(data) > 100:
            break

drawing = data[50]['drawing']

for stroke in drawing:
    stroke = np.array(stroke).T
    pen.penup()
    for point in stroke:
        pen.goto(point[0], -point[1])
        pen.down()

In our exploration together we’ll use the following function:

def rotation_matrix(theta):
    return np.array([
        [np.cos(theta), -np.sin(theta)],
        [np.sin(theta), np.cos(theta)]])

Week 12: Bonus (Thanksgiving week)

Monday

No class the rest of the week (Thanksgiving break)

Week 13: Recursion and Other Topics

Monday

Wednesday

Note: instead of using the key-saving code I gave in the slides, a much simpler way is to simply go in Thonny Settings, General, and put in the Environment Variables:

LLM_GEMINI_KEY=

and paste the key in the right-hand side (without quotes). Then restart Thonny.

Thursday

Lab: Bear-Fish Simulation

Friday

Week 14: Inheritance

Monday

Wednesday