ariannedee / python-foundations-3-weeks

40 stars 69 forks source link

Hands-on Python Foundations in 3 Weeks

This is the code for the O'Reilly Live Training - Hands-on Python Foundations in 3 Weeks presented by Arianne Dee

Before the class, please follow these instructions:

  1. Install Python
  2. Install PyCharm
  3. Install Git
  4. Clone the code
  5. Make sure that you can run Python in PyCharm

Set up instructions

1. Install Python

Note: some computers come with Python 2 preinstalled. For this course, you'll need Python 3.6 or higher version (like 3.10).

Go to https://www.python.org/downloads/

Mac/Linux: Follow the prompts and install using the default settings.

Windows:

2. Download PyCharm CE

Download the free, community edition https://www.jetbrains.com/pycharm/download/

Install, open, and use the default settings.

3. Install Git

Follow your operating system instructions if you don't already have Git installed: Git install instructions

4. Clone the course repository

Get the code for this course using Git.

Option 1

If you aren't familiar with Git, you can use PyCharm to clone a Git repository.

In PyCharm, when choosing which project to open, choose "Get from VCS" (clone from Git, which is a version control system)

See full instructions

Option 2

If you know Git, clone the repository and then open the python-foundations-3-weeks folder in PyCharm.

5. Make sure that you can run Python in PyCharm

With the python-foundations-3-weeks folder open in Pycharm:

  1. In the left panel, navigate to examples/week_1/example_1_first_code.py and double click to open it in the editor

  2. On the open file, right click and select Run 'example_1_first_code'

  3. In the Run tab on the bottom, you should see Process finished with exit code 0

  4. Otherwise, if you got an error (exit code 1 in red), follow the instructions for setting your Python version in PyCharm below

If you received an error running example_1_first_code, set your Python version in PyCharm

On a Mac:

On a PC:

Once in Settings:

If you are having trouble configuring your Python version, you can find visual instructions here: Python interpreter setup

Outline and resources

Rough week-by-week outline with links to relevant interactive scenarios and pre-recorded video lessons.

Interactive scenario list - Hands-On Python Foundations Scenarios

Video lesson 1 - Introduction to Python

Video lesson 2 - Next Level Python

Week 1

Getting started with Python

1. Running Python

Run Python in interactive and script mode

Interactive scenario 1 (steps 1 & 2) / Video 1 lesson 1.2 (0:00 - 2:00 and 12:00 - 13:45)

2. Math

Using operators and importing the math module

Interactive scenario 1 (steps 3 - 5) / Video 1 lesson 2.1 (2:00 - 12:00)

3. Variables

Working with variables, naming rules and keywords

Interactive scenario 2 (step 1) / Video 1 lesson 2.2

4. Types

Basic data types, errors and type casting

Interactive scenario 2 (steps 2 - 4) / Video 1 lesson 2.1 and Video 1 lesson 2.3

5. Text formatting

String concatination, formatting and interpolation

Interactive scenario 2 (steps 5 & 6) / Video 1 lesson 2.7

6. Functions

Defining your own functions

Interactive scenario 3 (step 1) / Video 1 lesson 2.6

7. Boolean expressions

True and false expressions, comparisons and methods

Interactive scenario 3 (step 2) / Video 1 lesson 3.2

8. Conditionals

If-elif-else statements

Interactive scenario 3 (step 3) / Video 1 lesson 3.3

9. Loops

While and for loops

Interactive scenario 3 (step 4) / Video 1 lesson 4.1 (while loops) and Video 1 lesson 4.4 (for loops)

Week 2

Writing simple scripts

1. Lists

Interactive scenario 4 (step 1) / Video 1 lesson 4.3

2. Dictionaries

Interactive scenario 4 (step 2) / Video 2 lesson 1.3

3. Tuples and sets

Interactive scenario 4 (steps 3 & 4) / Video 1 lesson 5.2

4. Exceptions

Catching and throwing errors/exceptions

Interactive scenario 5 (steps 1 & 2) / Video 2 lesson 1.4

5. Files

Reading and writing to text files and CSV files

Interactive scenario 5 (steps 3 - 5) / Video 2 lesson 2 (lessons 2.1 - 2.3)

6. HTTP requests

Making GET and POST requests using the requests library

Interactive scenario 5 (steps 1 & 4) / Video 2 lesson 7.1

7. APIs

Getting data from APIs

Interactive scenario 5 (steps 2, 3 & 5) / Video 2 lesson 7.5

8. Command line overview

No interactive scenario / Video 2 lesson 3.1

9. Script arguments

No interactive scenario or video lesson

Code examples in examples/week_2/example_23_args.py and examples/week_2/example_24_click.py

Week 3

Working with real-world applications

1. Pip

Installing external packages with pip

Interactive scenario 7 (steps 2 - 4) / Video 2 lesson 3.2

2. Virtual environments

Managing project environments with venv

Interactive scenario 7 (step 5) / Video 2 lesson 3.3

Connecting PyCharm to your virtual environment: instructions

3. Setting up projects

Working with venv, git and GitHub

No interactive scenario / Video 2 lesson 3.4 and 3.5

4. Classes

Using and creating classes

Interactive scenario 8 / No video lesson

5. Dunder methods

Understanding dunder methods

Interactive scenario 8 step 2 / No video lesson

6. Modules and packages

Imports, init.py, namespaces, scope and name.

Interactive scenario 9 / Video 2 lesson 5

7. Code hosting

Options for storing your code on the internet.

No interactive scenario / Video 2 lesson 9

FAQs

Can I use Python 2?

No, Python 2 is out of date. Please download a version that is at least Python 3.6.

Can I use a different code editor besides PyCharm?

Yes, but it is only recommended if you are already know it and are comfortable navigating to different files and running commands in the command line. If it has syntax highlighting for Python, that is ideal.

If you are using VS Code, make sure the Python plugin is installed.

PyCharm can't find Python 3

Follow the instructions for Python interpreter setup