Jed Rembold
April 27, 2026

Python is a dynamically typed language: we can change around what type of object is assigned to different variables whenever we want
We can indicate these types by using type hints or type annotations
def greet(name: str) -> str:
return f"Hello, {name}!")You can specify what type a variable should have by including the type after a colon when you declare the variable name
user_name: str = "Jed"
age: int = 40
is_living: bool = TrueIf you have compound structures, you can indicate the contents:
profs: list[str] = ['Jed', 'Calvin', 'Fred']
prof_start: tuple[str, int] = ('Jed', 2015)
profs_start: list[tuple[str, int]] = [
('Jed', 2015), ('Calvin', 2022)
]
prof_dict: dict[str, int] = {'Jed': 2025}Even more than variable annotations, function annotations can be extremely useful to define input and output types
def myfunc(x: int, y: float, z: bool = True) -> float:
if z:
return x * y
else:
return x / yHints come before any default values
Use the -> |||type||| syntax to
specify what will be returned
Sometimes, you do want to allow for situations where a variable might have multiple possible types
NoneYou can use the | symbol to indicate
multiple variable types:
def index_finder(
array: list[str],
target: str
) -> int | None:
for i, elem in enumerate(array):
if elem = target:
return i
If you are just getting started tracking a folder, you need to initialize Git in that folder
git init
.git folder to your folder, where Git stores
all its contentPerhaps the most used command will be to check the current status of Git in your folder
git status
which will print out information regarding the current state of the files
git add {file/folder name}
git commitGit has a logging function that will allow you to see information about your repository history
git logThere are a ton of customizations you can do to this output, but some include
--all shows the log of all branches, not
just the current--graph shows the connecting lines
between commits, including branching--decorate prints short names of
references--oneline compresses snapshot output to
fit on a single line for compactnessSometimes you might need to see what has changed between two states
The Git diff command will display an
output of all changes between two points
git diff {initial} {final} {filename}
{initial} is taken to be the
last commit and {final} to be the current
state of the files{filename} is not given, it will show
diffs on all files that have changedA history is of limited use if you can’t backtrack or move through it
The Git checkout command allows you
to “move” what you are currently looking at to a different commit
git checkout {desired commit}
Note that checking out a past commit actually changes the contents of your folder to reflect what it looked like at that time!
So far we have great ways to manage our local histories, but still not great ways to collaborate
Git has a concept of remotes, which are basically just copies of a repository kept on a (most of the time) remote server
Git works locally 99% of the time, so there are special commands to use when you want to “sync” contents between your local repository and the remote repository
Before either can be done, we need to inform Git of where the remote for a given repository exists
git remote add {name} {url}
{name} is by convention
origin unless you are connecting multiple
remotes{url} is the address where that remote
can be reachedOften, you might be given a remote address initially, and need to copy that repository over to your local system
Git calls this cloning a repository
git clone {remote url} {directory name}
{remote url} is the url of where the
remote lives{directory name} is the local directory
you want to copy that remote repository into
This automatically sets up a remote for the new local git repository
In order for the remote to be useful, we need to let it know what we have done locally
Git calls this pushing changes to the remote
git push {remote name} {local branch}:{remote branch}Typing all that in can get old, so we can specify it once by saying
git branch --set-upstream-to={remote name}/{remote branch}
at which point in the future we could just do
git pushOn multi-computer setups, it is possible that another system uploaded content to the remote that you do not yet have locally
Git calls this fetching from the remote
git fetch
fetchGets the remote information, but does not merge it with your local content
To do both at the same time (which is what you usually want), you can do
git pull