Practical Python Programming

Overview

Welcome!

When I first learned Python nearly 25 years ago, I was immediately struck by how I could productively apply it to all sorts of messy work projects. Fast-forward a decade and I found myself teaching others the same fun. The result of that teaching is this course--A no-nonsense treatment of Python that has been actively taught to more than 400 in-person groups since 2007. Traders, systems admins, astronomers, tinkerers, and even a few hundred rocket scientists who used Python to help land a rover on Mars--they've all taken this course. Now, I'm pleased to make it available under a Creative Commons license. Enjoy!

GitHub Pages | GitHub Repo.

--David Beazley (https://dabeaz.com), @dabeaz

What is This?

The material you see here is the heart of an instructor-led Python training course used for corporate training and professional development. It has been in continual development since 2007 and battle tested in real-world classrooms. Usually, it's taught in-person over the span of three or four days--requiring approximately 25-35 hours of intense work. This includes the completion of approximately 130 hands-on coding exercises.

Target Audience

Students of this course are usually professional scientists, engineers, and programmers who already have experience in at least one other programming language. No prior knowledge of Python is required, but knowledge of common programming topics is assumed. Most participants find the course challenging--even if they've already been doing a bit of Python programming.

Course Objectives

The goal of this course is to cover foundational aspects of Python programming with an emphasis on script writing, data manipulation, and program organization. By the end of this course, students should be able to start writing useful Python programs on their own or be able to understand and modify Python code written by their coworkers.

Requirements

To complete this course, you need nothing more than a basic installation of Python 3.6 or newer and time to work on it.

What This Course is Not

This is not a course for absolute beginners on how to program a computer. It is assumed that you already have programming experience in some other programming language or Python itself.

This is not a course on web development. That's a different circus. However, if you stick around for this circus, you'll still see some interesting acts--just nothing involving animals.

This is not a course for software engineers on how to write or maintain a one-million line Python application. I don't write programs like that, nor do most companies who use Python, and neither should you. Delete something already!

Take me to the Course Already!

Ok, ok. Point your browser HERE!

Community Discussion

Want to discuss the course? You can join the conversation on Gitter. I can't promise an individual response, but perhaps others can jump in to help.

Acknowledgements

Llorenç Muntaner was instrumental in converting the course content from Apple Keynote to the online structure that you see here.

Various instructors have presented this course at one time or another over the last 12 years. This includes (in alphabetical order): Ned Batchelder, Juan Pablo Claude, Mark Fenner, Michael Foord, Matt Harrison, Raymond Hettinger, Daniel Klein, Travis Oliphant, James Powell, Michael Selik, Hugo Shi, Ian Stokes-Rees, Yarko Tymciurak, Bryan Van de ven, Peter Wang, and Mark Wiebe.

I'd also like to thank the thousands of students who have taken this course and contributed to its success with their feedback and discussion.

Questions and Answers

Q: Are there course videos I can watch?

No. This course is about you writing Python code, not watching someone else.

Q: How is this course licensed?

Practical Python Programming is licensed under a Creative Commons Attribution ShareAlike 4.0 International License.

Q: May I use this material to teach my own Python course?

Yes, as long as appropriate attribution is given.

Q: May I make derivative works?

Yes, as long as such works carry the same license terms and provide attribution.

Q: Can I translate this to another language?

Yes, that would be awesome. Send me a link when you're done.

Q: Can I live-stream the course or make a video?

Yes, go for it! You'll probably learn a lot of Python doing that.

Q: Why wasn't topic X covered?

There is only so much material that you can cover in 3-4 days. If it wasn't covered, it was probably because it was once covered and it caused everyone's head to explode or there was never enough time to cover it in the first place. Also, this is a course, not a Python reference manual.

Q: Do you accept pull requests?

Bug reports are appreciated and may be filed through the issue tracker. Pull requests are not accepted except by invitation. Please file an issue first.

Comments
  • Link giving 404

    Link giving 404

    on this page https://github.com/dabeaz-course/practical-python/blob/master/Notes/01_Introduction/00_Overview.md

    the first link https://github.com/dabeaz-course/practical-python/blob/master/Notes/01_Introduction/01_Python is giving 404

    opened by satyaakam 7
  • Exercise 1.9: inclusive or exclusive range

    Exercise 1.9: inclusive or exclusive range

    From the description it is not clear if the extra payment start and/or end month should be included in the range. The exercise asks for "4 years starting in year 5", the code shows an exclusive range [60, 108], but the solution uses an inclusive range with ">=" and "<=" which results in 49 months.

    opened by Funatiq 5
  • Mortgage

    Mortgage

    I tried to solve the Mortgage Exercise.

    principal = 500000.0
    rate = 0.05
    payment = 2684.11
    total_paid = 0.0
    extra_payment_start_month = 61
    extra_payment_end_month = 108
    extra_payment = 1000
    month = 0
    
    while principal > 0:
        month = month + 1
        if month >= extra_payment_start_month and month <= extra_payment_end_month:
            principal = principal * (1 + rate / 12) - payment - extra_payment
            total_paid = total_paid + payment + extra_payment
        else:
            principal = principal * (1 + rate / 12) - payment
            total_paid = total_paid + payment
        if principal < 0:
            total_paid = total_paid+principal
            principal = 0
        print(month,total_paid,principal)
    
    print('Total paid',total_paid)
    print('Month', month)
    

    However. I get different numbers. Not only for the corrected payment and principal at the end....even before.

    I honestly cannot find an error in my code?! Any advise or hint?

    opened by mar-due 4
  • Section 1.1: false statement about the REPL

    Section 1.1: false statement about the REPL

    Warning: It is never possible to paste more than one Python command (statements that appear after >>>) to the basic Python shell at a time. You have to paste each command one at a time.

    This is false, at least on FreeBSD with xfce4-terminal. I've been using Python for 6 years and can't remember this ever being true.

    opened by yujiri8 4
  • There should be transition links between chapters/modules

    There should be transition links between chapters/modules

    going back to the content to navigate between chapters is a bit tedious. It would be nice to have a "next" link somewhere to progress through the chapters.

    opened by mertzjames 4
  • Broken links in section 3.2 More on Functions

    Broken links in section 3.2 More on Functions

    There are three links in the 3.2 More on Functions page, which when clicked go to 404 not found. I have not checked any other pages (yet...).

    Argument Passing When you call a function, the argument variables are names that refer to the passed values. These values are NOT copies (see section 2.7).

    An example of a column selector was given in Exercise 2.23. However, here’s one way to do it:

    You already explored this in Exercise 2.24. You'll need to insert the following fragment of code into your solution:

    opened by TheOutlawstar 3
  • Need help trying to execute .py files on git bash

    Need help trying to execute .py files on git bash

    Hi, so I am trying to follow this course. I have anaconda 3 installed (using python 3.8.3) and git bash.

    So to start the python interpreter on git bash, I typed: winpty python which worked fine.

    When I tried to execute a file, hello.py file for example, I would type: python hello.py it only works if the file is located C:\Users\username

    I am now working on 1.2 A First Program. In the exercise for the bouncing ball, the file required is stored here: C:\Users\username\GitHub Projects\practical-python\Work #bounce.py

    But because the file #bounce.py is located in a subfolder, I can't execute the script by typing: python bounce.py

    I am rather new to working in a terminal and unclear about environment variables and paths, what should I do in this situation? I want to be able to get the same output in git bash as shown on the course page.

    opened by wils205401 3
  • exercise1_10

    exercise1_10

    Why can't I get my loop to run like the example? I have been messing with it for a while. I have the right answer but mine looks different lol. Specifically my extra_payment_start_month is set to 60. `

    mortgage.py

    Exercise 1.7

    m = 500000.00 i = 0.05 p = 2684.11 t = 0.00 month = 0

    extra_payment_start_month = 60 extra_payment_end_month = 108 extra_payment = 1000

    while m > 0: if (month >= extra_payment_start_month) and (month < extra_payment_end_month): m = m * (1+i/12) - p - extra_payment t = t + p + extra_payment month += 1 print('BONUS','month:', month, 'paid:', round(t,2), "Remaining principle:", round(m,2)) continue if m <= p: t += m m = 0 month += 1 print("LAST", 'month:', month, 'paid:', round(t,2), "Remaining principle:", round(m,2)) break m = m * (1+i/12) - p t = t + p month += 1

    print("OUTER", 'month:', month, 'paid:', round(t,2), "Remaining principle:", round(m,2))
    

    `

    opened by josimp 3
  • Make examples in '02_Containers.md' executable

    Make examples in '02_Containers.md' executable

    This PR makes example of list construction when reading from a file executable.

    There is also an issue with "Dict Construction" from file example. It gives an error because 'Data/prices.csv' file has an empty last row. I'd make a change to account for that but not sure if this clutters example clarity too much:

    prices = {} # Initial empty dict
    
    with open('Data/prices.csv', 'rt') as f:
        for line in f:
            row = line.split(',')
            if len(row) >= 2: # Ensure enough data in a row
                prices[row[0]] = float(row[1])
    

    If this change is desirable, I'll update this PR.

    opened by echasnovski 3
  • Typo section 2.1 'ommitted'

    Typo section 2.1 'ommitted'

    "Sometimes the () are ommitted in the syntax." https://dabeaz-course.github.io/practical-python/Notes/02_Working_with_data/01_Datatypes.html

    opened by bobhilt 3
  • Exercise 1.7: You should get an answer of  966279.5999999957 not 966,279.6

    Exercise 1.7: You should get an answer of 966279.5999999957 not 966,279.6

    # mortgage.py
    
    principal = 500000.0
    rate = 0.05
    payment = 2684.11
    total_paid = 0.0
    
    while principal > 0:
        principal = principal * (1+rate/12) - payment
        total_paid = total_paid + payment
    
    print('Total paid', total_paid)
    

    Enter this program and run it. I get an answer of 966279.5999999957. Not 966,279.6.

    I can get an anwer of 966,279.6 by following:

    # Exercise 1.7
    
    
    principal = 500000.0
    rate = 0.05
    payment = 2684.11
    total_paid = 0.0
    
    while principal > 0:
        principal = principal * (1+rate/12) - payment
        total_paid = total_paid + payment
    
    print('Total paid', round(total_paid, 1))
    
    opened by Jock2018 3
  • Getting 404 when I try to run the exercise 1.4

    Getting 404 when I try to run the exercise 1.4

    Thanks a lot for making this course!!!

    It looks like something has changed on the bus tracker website and the example code gets an http return code 404. It seems like the URL should be updated to make the exercise work.

    opened by ikasovitch 1
Owner
Dabeaz LLC
Courses by David Beazley
Dabeaz LLC
Coursera learning course Python the basics. Programming exercises and tasks

HSE_Python_the_basics Welcome to BAsics programming Python! You’re joining thousands of learners currently enrolled in the course. I'm excited to have

PavelRyzhkov 0 Jan 5, 2022
A collection of simple python mini projects to enhance your python skills

A collection of simple python mini projects to enhance your python skills

PYTHON WORLD 12.1k Jan 5, 2023
Python Eacc is a minimalist but flexible Lexer/Parser tool in Python.

Python Eacc is a parsing tool it implements a flexible lexer and a straightforward approach to analyze documents.

Iury de oliveira gomes figueiredo 60 Nov 16, 2022
Repository for learning Python (Python Tutorial)

Repository for learning Python (Python Tutorial) Languages and Tools ?? Overview ?? Repository for learning Python (Python Tutorial) Languages and Too

Swiftman 2 Aug 22, 2022
A python package to avoid writing and maintaining duplicated python docstrings.

docstring-inheritance is a python package to avoid writing and maintaining duplicated python docstrings.

Antoine Dechaume 15 Dec 7, 2022
advance python series: Data Classes, OOPs, python

Working With Pydantic - Built-in Data Process ========================== Normal way to process data (reading json file): the normal princiople, it's f

Phung Hưng Binh 1 Nov 8, 2021
A comprehensive and FREE Online Python Development tutorial going step-by-step into the world of Python.

FREE Reverse Engineering Self-Study Course HERE Fundamental Python The book and code repo for the FREE Fundamental Python book by Kevin Thomas. FREE B

Kevin Thomas 7 Mar 19, 2022
A simple USI Shogi Engine written in python using python-shogi.

Revengeshogi My attempt at creating a USI Shogi Engine in python using python-shogi. Current State of Engine Currently only generating random moves us

null 1 Jan 6, 2022
Python-slp - Side Ledger Protocol With Python

Side Ledger Protocol Run python-slp node First install Mongo DB and run the mong

Solar 3 Mar 2, 2022
Python-samples - This project is to help someone need some practices when learning python language

Python-samples - This project is to help someone need some practices when learning python language

Gui Chen 0 Feb 14, 2022
Valentine-with-Python - A Python program generates an animation of a heart with cool texts of your loved one

Valentine with Python Valentines with Python is a mini fun project I have coded.

Niraj Tiwari 4 Dec 31, 2022
A curated list of awesome tools for Sphinx Python Documentation Generator

Awesome Sphinx (Python Documentation Generator) A curated list of awesome extra libraries, software and resources for Sphinx (Python Documentation Gen

Hyunjun Kim 831 Dec 27, 2022
API Documentation for Python Projects

API Documentation for Python Projects. Example pdoc -o ./html pdoc generates this website: pdoc.dev/docs. Installation pip install pdoc pdoc is compat

mitmproxy 1.4k Jan 7, 2023
🏆 A ranked list of awesome python developer tools and libraries. Updated weekly.

Best-of Python Developer Tools ?? A ranked list of awesome python developer tools and libraries. Updated weekly. This curated list contains 250 awesom

Machine Learning Tooling 646 Jan 7, 2023
Run `black` on python code blocks in documentation files

blacken-docs Run black on python code blocks in documentation files. install pip install blacken-docs usage blacken-docs provides a single executable

Anthony Sottile 460 Dec 23, 2022
Legacy python processor for AsciiDoc

AsciiDoc.py This branch is tracking the alpha, in-progress 10.x release. For the stable 9.x code, please go to the 9.x branch! AsciiDoc is a text docu

AsciiDoc.py 178 Dec 25, 2022
📖 Generate markdown API documentation from Google-style Python docstring. The lazy alternative to Sphinx.

lazydocs Generate markdown API documentation for Google-style Python docstring. Getting Started • Features • Documentation • Support • Contribution •

Machine Learning Tooling 118 Dec 31, 2022
A Python module for creating Excel XLSX files.

XlsxWriter XlsxWriter is a Python module for writing files in the Excel 2007+ XLSX file format. XlsxWriter can be used to write text, numbers, formula

John McNamara 3.1k Dec 29, 2022
API spec validator and OpenAPI document generator for Python web frameworks.

API spec validator and OpenAPI document generator for Python web frameworks.

1001001 249 Dec 22, 2022