An Introduction to Python
This page has not been updated since 2020. For a current Python course, go to AP Computer Science Principles (Python) at 1729math.com. It teaches the same fundamentals as a full interactive course, with problems you write and run in the browser, and it is free. The lectures below still work if you want them.
This is an introduction to Python. Python is the best language to learn as an introduction to computer programming. It is also the most popular language taught at the introductory level at universities. Its syntax is readable, expressive, and flexible yet powerful.
This introduction covers only the essentials of Python, enough to take on some of my other courses, including Image Recognition with Neural Networks and Discrete Fourier Transform, both now at 1729math.com. For an excellent and more comprehensive introduction to Python, especially as it relates to data science, see Ryan Soklaski's Python Like You Mean It.
It is recommended that you download the Anaconda distribution which includes latest version of Python, many packages and libraries for scientific computing and a package manager. The code for the lecture exercises below, however, can also be run on the cloud on MyBinder.
Lecture 1: Basic Data Types and Operations
Numbers(int, float, complex). Booleans. NoneType. Variables. Math Operations. Logical Operations. Comparison Operations.- Lecture 1 Exercise (Download, NBViewer(Static Renderer)) Run an interactive version of this code on MyBinder.
Lecture 2: Conditionals
If Block. If/If/If. If/Elif/Elif. If/Elif/Else. Ternary Operator.- Lecture 2 Exercises(Download, NBViewer(Static Renderer)) Run an interactive version of this code on MyBinder.
Lecture 3: Loops
For vs While. Range Function. Direct vs. Indirect Loops. User Input. Break and Continue. Nested Loops.- Lecture 3 Exercises(Download, NBViewer(Static Renderer)) Run an interactive version of this code on MyBinder.
Lecture 4: Lists
Lists. Useful List Functions. Indexing. Slicing. List Comprehensions.- Lecture 4 Exercises(Download, NBViewer(Static Renderer)) Run an interactive version of this code on MyBinder.
