1 of 14

Python Fundamentals

WoCCode Summer Bootcamp 2023

2 of 14

What we WILL cover

What we WON’T cover

  • Functionalities that make Python different from other languages,�pros and cons
  • Explain what Python is doing in the background - to give you intuition for debugging and navigating documentation
  • Built-in Python objects
  • Introduction to concept of namespaces
  • Introduction to Numpy
  • Introduction to IPython commands for efficiency testing
  • Introduction to writing functions
  • Docstrings and why they are important
  • Writing Python scripts
  • Importing your own libraries to Python
  • Introduction to computer programming logic
  • Introduction of Python syntax
  • Specialty packages like scipy, Pandas, seaborn, or Astropy (brief mentions only)

Free online Python tutorials:

3 of 14

Jupyter Notebook: Download Method 1

Step 3 (in terminal):

git clone git@github.com:woccode/summer-bootcamp-2023.git

cd summer-bootcamp-2023/Session-2/

jupyter notebook 2-PythonFundamentals.ipynb

Step 1: click

Step 2: copy�SSH or HTTPS

Done

Just watching

Need help

4 of 14

Jupyter notebook: Download Method 2

Step 2 (in terminal):

cd ~/Downloads/

jupyter notebook 2-PythonFundamentals.ipynb

Step 1: Click to download

5 of 14

Let’s get started! Built-in Python objects

Covered:

  • int and float type objects
  • strings, dictionaries, and lists
  • for loops, logic statements, if/else
  • using the “{}”.format() to produce formatted strings
  • Python zip function

Not covered (see linked resources):

6 of 14

A pause to consider Python Namespaces

import kungfu

import kungfu as kf

from kungfu import kick

KF

GOOD PRACTICE TIP:

7 of 14

Let’s get into Math: Introduction to Numpy

When you:

import numpy as np

you can access numpy libraries with the prefix np.

For example,

x = np.array([1., 2., 3.])

see Jupyter notebook example

8 of 14

Defining Functions – and more importantly – DocStrings

9 of 14

Scripting in Python - example code

If you did not clone the repo, download here

Done

Just watching

Need help

10 of 14

Scripting in Python

First line needed to execute it from command line.

Import libraries and write code as usual.

Put special numbers and global settings at the top

11 of 14

Scripting in Python

12 of 14

Scripting in Python

Another option:

python taylor_expansions.py 10

13 of 14

Importing your own Python libraries - Method 1

14 of 14

Importing your own Python libraries - Method 1

To make it permanent, include the export command in your�.bashrc (Linux) or .bash_profile (MacOS) file