oim3640
"OIM3640: GitHub settings"
You can also use the terminal (command line) for file navigation:
cd folder
cd ..
ls
dir
mkdir folder
pwd
conda activate base
conda init powershell
Terminal → Default Profile → Windows
oim3640/ # Main course repository (public) ├── notebooks/ # Jupyter notebooks (from Think Python 3) ├── code/ # Python scripts and modules ├── data/ # Data files ├── logs/ # Learning logs (Markdown files: s01.md, s02.md, ...) ├── mini_projects/ # Mini projects (may be here or separate repos) └── README.md # Portfolio homepage
import this
import antigravity
.ipynb
oim3640/notebooks
Key ideas (not syntax!):
SyntaxError
NameError
TypeError
Read the error messages — they tell you what went wrong!
Main concepts:
Every piece of data in Python has a type:
int
42
float
3.14
str
"hello"
bool
True
False
Use type(x) to check what type something is.
type(x)
A variable is a name that refers to a value:
message = "Hello, World!" n = 42 pi = 3.14159
Good naming matters! Which is better?
# Option A x = 26.2 # Option B marathon_miles = 26.2
Rules (will cause errors if broken):
Name
name
if
for
while
Style (follow for readability):
lowercase_with_underscores
student_count
sc
i
j
An expression is code that produces a value:
+
-
*
3 + 4
7
/
7 / 2
3.5
//
7 // 2
3
%
7 % 2
1
**
2 ** 3
8
The modulo operator gives the remainder after division:
17 % 5 # → 2 (17 = 5×3 + 2) 10 % 2 # → 0 (10 is even, no remainder) 7 % 10 # → 7 (7 < 10, so remainder is 7)
Common uses:
n % 2 == 0
n % 10
(hour + 5) % 12
2 + 3
len("hello")
x = 5
print("Hi")
# This is a statement (assignment) total = 100 + 50 # This is an expression (used in a statement) print(total * 0.08)
# Calculate the tip (15% of total) tip = total * 0.15
When to comment:
Open Chapter 1 & 2 notebooks (chap01.ipynb, chap02.ipynb)
chap01.ipynb
chap02.ipynb
Work through the examples and exercises.
Questions? Ask now!
logs/s03.md
Next session: Functions (Chapter 3)
global styles