Python Programming · Week 1
Hyeongmin Lee · SeoulTech, Dept. of Electronic Engineering
About me
Assistant Professor · Dept. of Electronic Engineering · ViViD Lab
I teach computers to see, and to imagine.
no experience needed
we start from zero
hands-on
you write code every week
your first language
the ideas transfer to every language
theory video
the idea
practice video
code along
exercise
try it yourself
in-person class
solutions · Q&A
↻ every week · everything on e-Class
Exercise solutions appear only in class.
10%
attendance
30%
midterm
30%
final
30%
homework
homework = light weekly exercises · the easiest points in this course
written on paper, code by hand
write code · find the error · predict the output
The exercises are the exam prep.
Spider-Man: Homecoming (2017)
“If you're nothing without the suit,
then you shouldn't have it.”
Train without the suit.
lectures in English
code · error messages · documentation: all in English anyway
Korean recap at the end of every class
so nobody gets lost
office
Changhak Hall 334-1
hyeongmin.lee@seoultech.ac.kr
topics
course · career · anything
Email me first to set a time. Do not sit alone with a problem for a week.
A question
import turtle
t = turtle.Turtle()
t.speed(0)
for i in range(300):
t.forward(i * 0.5)
t.left(91) What do these six lines do?
six lines.
In a few weeks, you write this yourself.
The core idea
nothing more · nothing less
one wrong instruction → your friend is lost
The golden rule
the computer never guesses
The core idea
no meanings · no intentions · only operations
source code
hello.py
a plain text file · you write it
interpreter
Python
a program that reads your text, line by line
result
the computer acts
text on screen · a drawing · a file
“Python” names both the language and the interpreter.
print("Good morning")
print("Good afternoon")
print("Good evening") Good morning
Good afternoon
Good evening
Top to bottom. One line at a time.
The same task, twice.
C
#include <stdio.h>
int main(void) {
printf("Hello, world!\n");
return 0;
} Python
print("Hello, world!") You do not need to read the C. That is the point.
data
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4], [1, 4, 9, 16], "o-")
plt.show()
images
from skimage import data, filters
edges = filters.sobel(data.astronaut()[..., 0])
automation
from pathlib import Path
for f in Path("photos").glob("*.jpg"):
f.rename("trip_" + f.name) IMG_2041.jpg → trip_IMG_2041.jpg
IMG_2042.jpg → trip_IMG_2042.jpg
… × 1,000
AI
from transformers import pipeline
clf = pipeline("sentiment-analysis")
clf("I love this course!") [{'label': 'POSITIVE',
'score': 0.9998}]
AI speaks Python.
editor
write
where you type the text · VS Code
interpreter
run
reads your file, makes the computer act · Python
terminal
command
where you talk to the computer directly
Lost later in the course? Come back to this picture.
Next steps
Watch it with your hands on the keyboard.
See you in class.