Chris Walshaw
 Teaching
 Research
 Enterprise & KE
 Music
 Contact

Programming Foundations in Python

Welcome to Programming Foundations in Python, a 10-topic course in the basics of coding with the popular programming language Python.

Each topic has a YouTube playlist with 6-10 short videos (roughly an hour long) accompanied by a zip file of downloadable standalone examples. The examples all use Python but I give comparisons with other popular languages (such as C, Java and JavaScript) along the way.

Obviously you can dip in and out of the videos, using the lists of contents below as an index, but if you want to take the whole course, I recommend watching one topic a week (or one a day if you are in a hurry) and then practising with the examples to build your skills up.

Please feel free to leave comments on the videos (questions or constructive criticism) and I will reply to you as soon as I get the chance. I also recommend subscribing to my YouTube channel for addition courses that I will be releasing.

Topic 01 Introduction

YouTube Introduction playlist:

  • Video 01-1 - What is programming: Objectives. Python textbooks. What is computer programming? What is a computer program? What is a programming language? What is syntax? Programming problems.
  • Video 01-2 - What is Python: What is Python? Installing Python. What is the Python shell?
  • Video 01-3 - Using the Python shell: First example. Hello world! Calculator. Syntax errors. Saving your work.
  • Video 01-4 - First Python program & examples: Python examples (downloadable). HelloWorld.py. Running Python code in IDLE. More examples - text analysis, file management, pizzas GUI.
  • Video 01-5 - Turtle - getting started: Turtle graphics. Yin-Yang example. Modifying the code. Variables & hard-coding.
  • Video 01-6 - Turtle - simple shapes: Turtle principles. Drawing a square. Comments. Importing Turtle. Pen up / down. More commands.
  • Video 01-7 - Summary: Summary. Take-aways.

Downloadable Introduction examples

Topic 02 Variables

YouTube Variables playlist:

  • Video 02-1 - Introduction & input(): Objectives. Double-clicking. HelloWorld new version. Making use of input().
  • Video 02-2 - Motivation & HelloName: Motivation. HelloName. Variables ... how? Declaring.
  • Video 02-3 - Assigning & Naming: Assigning. (Re)Assigning. Lots of variables. Naming. Rules. Conventions.
  • Video 02-4 - Numbers: Numbers. Data types. Integers. Strings. Temporary / permanent storage?
  • Video 02-5 - Data types & Operators: Data types. Strings vs integers. Other data types. Operators.
  • Video 02-6 - Examples & Formatting: HelloAge vs HelloDOB (date of birth). Formatting (f-strings). HelloDOB_fStrings.
  • Video 02-7 - Calculator examples: Calculator examples. String addition. Addition. Subtraction.
  • Video 02-8 - Short cuts & randoms: Short cuts. Addition shorter. Addition even shorter. Addition in one line.
  • Video 02-9 - Summary: Random numbers. Summary.

Downloadable Variables examples

Topic 03 Decisions

YouTube Decisions playlist:

  • Video 03-1 - Introduction & motivation: Objectives. Motivation.
  • Video 03-2 - Conditionals: if statement: Conditionals: the if statement. Using if statements. Example 1 - Calculator (if). Flow of control. Conditional flow of control.
  • Video 03-3 - Conditionals: else statement: Conditionals: the else statement. Using else statements. Defensive programming.
  • Video 03-4 - Conditionals: elif statement, combined, indentation: Conditionals: the elif statement. Example 3 - Calculator (if+elif). Example 4 - Calculator (if+elif+elif). Defensive programming (2). Conditionals combined. Example 5 Calculator (if+elif+else). Indentation.
  • Video 03-5 - Concessions & booleans: Concessions. Example 6 - Concessions. The "+=" operator. Booleans. Example 7 - Concessions (booleans).
  • Video 03-6 - Concessions: in operator, or operator: Example 8 - Concessions (in operator). Comparison operators. Example 9 - Concessions (elif). Examples 10 & 11 - Concessions (or operator).
  • Video 03-7 - Concessions: nested ifs, and operator, not operator: Example 12 - Concessions (nested ifs). Example 13 - Concessions (and operator). Example 14 - Concessions (or operators). Example 15 - Concessions (booleans). The not operator. Example 16 - Concessions (not operator).
  • Video 03-8 - Choices, validation & summary: Choices, choices. Validation. Example 17 - Random Values (validation). Summary.

Downloadable Decisions examples

Topic 04 Functions

YouTube Functions playlist:

  • Video 04-1 - Introduction & motivation: Objectives. Motivation. Writing functions. Motivating Example - Turtle squares.
  • Video 04-2 - Calculator output example: Example 2 - Calculator. Declaring functions. Example 3 - Calculator output().
  • Video 04-3 - General principles: Flow of control. File structure. Execution. Quick check 1.
  • Video 04-4 - Arguments & Parameters: Arguments. Parameters. Example 4 - Calculator - generic output().
  • Video 04-5 - Calculator input examples: Example 5 - input() functions. Invoking a function which returns a value. output() vs input(). Duplication. Example 6 - input_int().
  • Video 04-6 - More Calculator examples: Example 7 - calculate(). Quick check 2. Quick check 3. Using a function as a parameter. Example 8 - Calculator input_and_convert().
  • Video 04-7 - Common problems: Problems with functions. Syntax functions. Example 9 - parameter naming. Scope. Example 10 - scope bug. Example 11 - parameters bug. Example 12 - arguments bug. Example 13 - arguments bug.
  • Video 04-8 - Defaults & summary: Defaults. Example 14 - defaults. Example 15 - return bug. Summary.

Downloadable Functions examples

Topic 05 Debugging

YouTube Debugging playlist:

  • Video 05-1 - Introduction & review: Objectives. Motivation. Syntax. Statements. Flow of control. Conditional Flow of control. Functions flow of control. Operators. Comments. Multi-line comments (docstrings). Quick check.
  • Video 05-2 - PyCharm: Debugging. PyCharm. Installation. Settings. Organising code.
  • Video 05-3 - PyCharm configuration: Open Project. Configuration. Running a program. Windows Firewall.
  • Video 05-4 - Breakpoints: Debugging. Practices. Breakpoints in PyCharm.
  • Video 05-5 - Example: Debugging a program. Calculator example. Screenshot. Debugging controls. Debugging process.
  • Video 05-6 - Other useful features: PyCharm features. Highlighting. Syntax errors, Renaming, Usages, Comments, Code Completion. Summary.

Downloadable Debugging examples

Topic 06 Loops

YouTube Loops playlist:

  • Video 06-1 - Introduction & motivation: Objectives. Motivation. Loop types.
  • Video 06-2 - The while loop: Syntax. Example 1 - stars. Output string. The += operator.
  • Video 06-3 - The for loop: Syntax. Example 2 - stars. The range() function. Example 3 - print counter.
  • Video 06-4 - for vs while: Examples 4 & 5 - user input. for vs while. Which to use?
  • Video 06-5 - The range() function & loop counters: range() continued. Example 6 - print counters. Loop counters - starting from 0 or 1. Quick check.
  • Video 06-6 - More loops: More loops. Example 7 - random values. Pseudo-code. Example 8 - concessions loop.
  • Video 06-7 - Controls: break & continue: Other loop controls. Example 9 - line numbers. The break statement. Example 10 - break. The continue statement. Example 11 - continue.
  • Video 06-8 - Nesting: Nested loops. Example 12 - fixed rectangle. Example 13 - square. Example 14 - variable rectangle.
  • Video 06-9 - Variable limits: Variable loop limits. Example 15 - triangle. Summary.

Downloadable Loops examples

Topic 07 Lists

YouTube Lists playlist:

  • Video 07-1 - Introduction & motivation: Objectives. Motivation.
  • Video 07-2 - List basics & initialisation: List notation. Accessing lists. Initialising a list. Example 1 (first list).
  • Video 07-3 - Loops & lists: Using loops & lists. Problems. The len() function. Example 2 (using len()). A better approach (enhanced for loop). Example 3 (using in). Quick check.
  • Video 07-4 - Functions & methods: The print_list() function. Example 4. List methods. Example 5 (list methods). List item methods. Example 6 (list item methods).
  • Video 07-5 - Numbers & lists: Lists of numbers. Example 7 (sorted randoms). Unique values. Example 8 (sorted unique randoms).
  • Video 07-6 - Sets: Sets. Using sets. Example 9 (set of randoms).
  • Video 07-7 - Built-in functions: Built-in functions (max, min, sum). Example 10 (built-in functions). Functions vs methods.
  • Video 07-8 - Indexing & slices: List indexing. Slicing. Slicing defaults. Slicing examples.
  • Video 07-9 - List algorithms: List function implementations. Minimum. Sum. Example 12 (local implementations). Summary.

Downloadable Lists examples

Topic 08 Strings

YouTube Strings playlist:

  • Video 08-1 - Introduction & motivation: Objectives. Motivation.
  • Video 08-2 - Formatting: Formatting. Format specifier. Numbers (scientific, currency, percentages). Justification.
  • Video 08-3 - Methods & functions: String methods. Functions used on Strings.
  • Video 08-4 - Operators & slicing: The in operator. Adding & "multiplying" strings. Substrings.
  • Video 08-5 - Loops & strings: Using loops with strings/characters. Aside: the print() function.
  • Video 08-6 - Comparison & classification: Alphabetic comparisons. Classification (alphabetic, alpha-numeric, whitespace, upper/lower case).
  • Video 08-7 - Search: Methods - .find(), .startswith(), .endswith(), .count(). Aside: chaining methods.
  • Video 08-8 - Text processing & counting: Removing punctuation. Removing whitespace. Counting letters & words - .split().
  • Video 08-9 - Text processing with dictionaries: The dictionary data structure. Word frequency. Summary.

Downloadable Strings examples

Topic 09 Files

YouTube Files playlist:

  • Video 09-1 - Introduction & opening: Objectives. Motivation.
  • Video 09-2 - Reading: File handling. Reading a file. Working with the file system. The with keyword. The read() function.
  • Video 09-3 - Spell checker & exceptions: Spell checker example. Exceptions. Exception handling. try ... except.
  • Video 09-4 - The file system & file lister: Accessing the file system. Using the os (operating system) module. Recursion. Example - file lister. Recursion and exceptions.
  • Video 09-5 - More examples: count, search, update, delete: Example - line count. Example - file search. Example - CRUD (create, read, update, delete) functionality.
  • Video 09-6 - Processing CSV files & web pages: Processing CSV files. Processing web pages. Example - basic browser. Example - letter frequency. Summary.

Downloadable Files examples

Topic 10 GUIs

YouTube GUIs playlist:

  • Video 10-1 - Introduction & tkinter: Objectives. Motivation. The tkinter module.
  • Video 10-2 - Windows, labels, sizing: Basic window. Labels. Geometry managers. Tkinter grid. Sizing.
  • Video 10-3 - Buttons: Buttons. Getting a response. Callback functions.
  • Video 10-4 - Text fields: Text fields. The Entry widget. Writing to a text field (via StringVar). Finessing - focus & read-only fields.
  • Video 10-5 - Check boxes & combo boxes: Check boxes. Binding to a BooleanVar. Combo boxes / drop-down lists.
  • Video 10-6 - Radio buttons: Radio buttons. Binding to an IntVar. Code efficiency - using lists/loops.
  • Video 10-7 - Pizza example: The Pizza app. Initial design. Lists & loops. Calculating the price.
  • Video 10-8 - Responsive design: Implementing responsive design. Expanding the data. Summary.

Downloadable GUIs examples


©