Everything you need for Intro and Advanced Python at CSU Stanislaus
Notebooks (.ipynb files) let you run Python one cell at a time, which is great for the study guide files and practice databases used in this course. Two things are required before a notebook will run in VS Code: the Jupyter extension, and the ipykernel package installed for your Python interpreter.
Ctrl+Shift+X on a PC or Cmd+Shift+X on a MacBook.ipynb file, then click Select Kernel in the top right corner and choose your Python interpreterOpen a terminal in VS Code (Ctrl+`) and run:
# if you're using a virtual environment, activate it first
venv\Scripts\activate
py -m pip install --upgrade pip
py -m pip install ipykernel -U --user
Open a terminal in VS Code (Ctrl+`) and run:
# if you're using a virtual environment, activate it first
source venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install ipykernel -U --user
If VS Code cannot find a kernel after installing ipykernel, close and reopen the notebook, then use Select Kernel again — the new kernel usually needs a moment to register.
CodeCheck.io gives you instant feedback on your code. These labs are used in class — practice them as much as you want.
. — any char except newline\d — digit [0-9]\D — non-digit\w — word char [a-zA-Z0-9_]\W — non-word char\s — whitespace\S — non-whitespace* — 0 or more+ — 1 or more? — 0 or 1 (optional){n} — exactly n times{n,m} — between n and m^ — start of string$ — end of stringre.match(p, s) — at startre.search(p, s) — anywherere.findall(p, s) — all matchesre.sub(p, r, s) — replacere.compile(p) — compile(abc) — capture group(?:abc) — non-capturea|b — a or b[abc] — any of a, b, c[^abc] — not a, b, or c\b — word boundaryPython doesn't have pointers like C/C++, but it uses references. Every variable holds a reference to an object, not the object itself.
# Both variables point to the SAME list
a = [1, 2, 3]
b = a # b is a reference to the same object
b.append(4)
print(a) # [1, 2, 3, 4] ← a changed too!
# Use .copy() or list() to avoid this
c = a.copy()
c.append(99)
print(a) # [1, 2, 3, 4] ← a unchanged