Mode of Work
- We are going to use Google Colab
- We are using Large Language Models (LLM) to generate Code
- Eg. Google Gemini, as it is built into Colab
- Bt you can any LLM you like
- We will use prompts to guide the LLMs
- The following Slides will present topic-based prompts
- Links to relevant information can be found on the resources page
Program Structure
- write a simple python program
- write a simple python program with an if statement
- explain that program
- explain colons and indentation
- write code for nested if
- write code for chained if
- write a simple python program with a loop
- what does range(5) mean
- write code for nested loops
Strings
- write a simple python program with a variable of type string
- generate examples of using string functions
- explain the usage of f-string
- explain formating within f-strings
Lists
- write a simple python program with a variable of type list
- generate examples of list slicing
- generate examples of using list functions
Dicts
- write a simple python program with a variable of type dict
- generate examples of using dict functions
- explain default within dict
Functions
- write a simple python program with a function definition
- write a simple python program with a function definition that gets a number as input and returns a number
- apply this function onto a list of numbers
- use map
- what is the difference between a list and an iterator
- explain higher order functions in python
- generate example code for reduce
Classroom Exercise 1
Create a function that that given a text counts the number of occurences per word.
Let the LLM generate the code and explain it.
List Comprehensions
- write a simple python program with a list comprehension
- explain list comprehensions
- add a filter to the previous program
- nest list comprehensions
Files
- write a simple python program that reads from a file
- read line by line
Classroom Exercise 2
Create a function that that given a list of two-dimensional tuples that represent cartesion coordinates, plots them on a two dimensional plane, connects them with lines, and calculates the length of the corresponding path.
- define a variable named coords that is a list of two-dimensional tuples that represent cartesion coordinates
- plot coords on a two dimensional plane
- plot a path connecting the points in coords
- connect points according to position in list
- write a function that calculates the length of a path
Classes
- write a simple python program with a class
- explain that class
- explain what methods are good for
- what is the role of __init__
- Explain instance generation
Classroom Exercise 3
Create a class that implements the Nearest Neighbor algorithm for finding the nearest point in a set of points.
- create a class named NearestNeighbor that has an empty constuctor
- it should have a method named fit with one parameter named instances
- this parameter is a list of tuples that represent cartesion coordinates
- it should have a soecond method called predict
- this method should deliver the cordinates of the nearest point