1. Python Programming
  2. First steps
    1. What is Python?
    2. What is needed to write a program?
    3. The source (code) of Python
    4. Python 2 vs. Python 3
    5. Installation
    6. Installation on Linux
    7. Installation on Apple Mac OSX
    8. Installation on MS Windows
    9. Installation of Anaconda
    10. Editors, IDEs
    11. Documentation
    12. Program types
    13. Python on the command line
    14. First script - hello world
    15. Examples
    16. Comments
    17. Variables
    18. Exercise: Hello world
    19. What is programming?
    20. What are the programming languages
    21. A written human language
    22. A programming language
    23. Words and punctuation matter!
    24. Types matter to Python (a bit)
    25. String vs int
    26. String vs float
    27. int and float
    28. Literals, Value Types in Python
    29. Floating point limitation
    30. Floating point -compare using round
    31. round
    32. Value Types in Numpy
    33. Rectangle (numerical operations)
    34. Multiply string
    35. Add numbers
    36. Add strings
    37. Exercise: Calculations
    38. Solution: Calculations
  3. Second steps
    1. Modules
    2. A main function
    3. The main function - called
    4. Indentation
    5. Conditional main
    6. Input - Output I/O
    7. print in Python 2
    8. print in Python 3
    9. print in Python 2 as if it was Python 3
    10. Exception: SyntaxError: Missing parentheses in call
    11. Prompting for user input in Python 2
    12. Prompting for user input in Python 3
    13. Python2 input or raw_input?
    14. Prompting both Python 2 and Python 3
    15. Add numbers entered by the user (oups)
    16. Add numbers entered by the user (fixed)
    17. Can we convert a string to int or float?
    18. How can I check if a string can be converted to a number?
    19. Converting string to int
    20. Converting float to int
    21. How can I check if a string can be converted to a number?
    22. Conditionals: if
    23. Conditionals: if - else
    24. Divide by 0
    25. Conditionals: if - else (other example)
    26. Conditionals: else if
    27. Conditionals: elif
    28. Ternary operator (Conditional Operator)
    29. Case or Switch in Python: match pattern matching
    30. Exercise: Rectangle
    31. Exercise: Calculator
    32. Exercise: Age limit
    33. Exercise: What is this language?
    34. Exercise: Standard Input
    35. Solution: Area of rectangle
    36. Solution: Calculator
    37. Solution: Calculator eval
    38. Solution: Age limit
    39. Solution: What is this language?
    40. STDIN vs Command line arguments
    41. Command line arguments
    42. Command line arguments - len
    43. Command line arguments - exit
    44. Exercise: Rectangle (argv)
    45. Exercise: Calculator (argv)
    46. Solution: Area of rectangle (argv)
    47. Solution: Calculator (argv)
    48. Solution: Calculator eval
    49. Compilation vs. Interpretation
    50. Is Python compiled or interpreted?
    51. Flake8 checking
    52. Pylint checking
  4. Numbers
    1. Numbers
    2. Operators for Numbers
    3. Integer division and the future
    4. Pseudo Random Number (uniform distribution)
    5. Fixed random numbers
    6. Rolling dice - randrange
    7. Random choice
    8. built-in method
    9. Exception: TypeError: 'module' object is not callable
    10. Fixing the previous code
    11. Exception: AttributeError: module 'random' has no attribute
    12. Exercise: Number guessing game - level 0
    13. Exercise: Fruit salad
    14. Solution: Number guessing game - level 0
    15. Solution: Fruit salad
  5. Comparison and Boolean
    1. if statement again
    2. Comparison operators
    3. Compare numbers, compare strings
    4. Do NOT Compare different types!
    5. Complex if statement with boolean operators
    6. Chained expressions
    7. Boolean operators
    8. Boolean truth tables
    9. Boolean values: True and False
    10. Using True and False in variables
    11. Comparison returns True or False
    12. Assign comparisons to variables
    13. Flag
    14. Use flag to skip first few lines
    15. Toggle
    16. Short circuit
    17. Short circuit fixed
    18. Does this value count as True or False?
    19. True and False values in Python
    20. Incorrect use of conditions
    21. Exercise: compare numbers
    22. Exercise: compare strings
    23. Solution: compare numbers
    24. Solution: compare strings
  6. Strings
    1. Single quoted and double quoted strings
    2. Long lines
    3. Multiline strings
    4. Triple quoted strings (multiline)
    5. Triple quoted comments - documentation
    6. String length (len)
    7. String repetition and concatenation
    8. A character in a string
    9. String slice (instead of substr)
    10. Change a string
    11. How to change a string
    12. String copy
    13. String functions and methods (len, upper, lower)
    14. index in string
    15. index in string with range
    16. Find all in the string
    17. rindex in string with range
    18. find in string
    19. in string
    20. index if in string
    21. Encodings: ASCII, Windows-1255, Unicode
    22. raw strings
    23. ord
    24. chr - number to character
    25. Exercise: one string in another string
    26. Exercise: Character to Unicode-8 - CLI
    27. Exercise: from Unicode to character - CLI
    28. Exercise: ROT13
    29. Solution: one string in another string
    30. Solution: compare strings
    31. Solution: to Unicode CLI
    32. Solution: from Unicode CLI
    33. Solution: Show characters based on Unicode code-points
    34. Solution: ROT13
  7. Other
    1. Infinite loop
    2. break
    3. continue
    4. While with many conditions
    5. while loop with many conditions
    6. ord in a file
    7. Strings as Comments
  8. Loops
    1. Loops: for-in and while
    2. for-in loop on strings
    3. for-in loop on list
    4. for-in loop on range
    5. Iterable, iterator
    6. for in loop with early end using break
    7. for in loop skipping parts using continue
    8. for in loop with break and continue
    9. while loop
    10. Infinite while loop
    11. While with complex expression
    12. While with break
    13. While True
    14. Testing the refactoring of the while loop
    15. Duplicate input call
    16. Duplicate input call with loop
    17. Eliminate duplicate input call
    18. do while loop
    19. while with many continue calls
    20. Break out from multi-level loops
    21. For-else
    22. Exercise: Print all the locations in a string
    23. Exercise: Number guessing game
    24. Exercise: Count unique characters
    25. Exercise: Convert for-loop to while-loop
    26. Solution: Print all the locations in a string
    27. Solution 1 for Number Guessing
    28. Solution 2 for Number Guessing (x)
    29. Solution 3 for Number Guessing (s)
    30. Solution for Number Guessing (debug)
    31. Solution for Number Guessing (move)
    32. Solution for Number Guessing (multi-game)
    33. Solution: Count unique characters
    34. Solution: Convert for-loop to while-loop
  9. Formatted strings
    1. format - sprintf
    2. printf using old %-syntax
    3. Examples using format with names
    4. Format columns
    5. Examples using format - alignment
    6. Format - string
    7. Format characters and types (binary, octal, hexa)
    8. Format floating point number
    9. Examples using format - indexing
    10. Format characters and types using f-format
    11. f-format (formatted string literals)
    12. Format floating point numbers using f-format
    13. Format braces, bracket, and parentheses
    14. parameterized formatter
    15. format binary, octal, hexa numbers
    16. Examples using format with attributes of objects
    17. raw f-format
    18. Format with conversion (stringifiation with str or repr)
  10. Lists
    1. Anything can be a list
    2. Any layout
    3. Access elements of a list
    4. List slice with steps
    5. Change a List
    6. Change sublist vs change element of a list
    7. Change with steps
    8. List assignment and list copy
    9. Shallow vs. Deep copy of lists
    10. join
    11. join list of numbers
    12. split
    13. for loop on lists
    14. in list
    15. Where is the element in the list
    16. Index improved
    17. [].insert
    18. [].append
    19. [].remove
    20. Remove element by index [].pop
    21. Remove first element of list
    22. Remove several elements of list by index
    23. Use list as a queue - FIFO
    24. Queue using deque from collections
    25. Fixed size queue
    26. List as a stack - LIFO
    27. stack with deque
    28. Exercies: Queue
    29. Exercise: Stack
    30. Exercise: MasterMind
    31. Solution: Queue with list
    32. Solution: Queue with deque
    33. Solution: Reverse Polish calculator (stack) with lists
    34. Solution: Reverse Polish calculator (stack) with deque
    35. Solution: MasterMind
    36. MasterMind to debug
    37. Debugging Queue
    38. sort
    39. sort numbers
    40. key sort of strings
    41. sort mixed values
    42. sort mixed values fixed with str
    43. sorting with sorted
    44. sort vs. sorted
    45. Sorted and change - shallow copy
    46. Sorting characters of a string
    47. range
    48. Looping over index
    49. Enumerate lists
    50. List operators
    51. List of lists
    52. List assignment
    53. List documentation
    54. Exercise: color selector menu
    55. Exercise: count digits
    56. Exercise: Create list
    57. Exercise: Count words
    58. Exercise: Check if number is prime
    59. Exercise: DNA sequencing
    60. Solution: menu
    61. Solution: count digits
    62. Solution: Create list
    63. Solution: Count words
    64. Solution: Check if number is prime
    65. Solution: DNA sequencing
    66. Solution: DNA sequencing other
    67. Solution: DNA sequencing using replace
    68. Solution: DNA sequencing using regex
    69. Solution: DNA sequencing with filter
    70. Solution: DNA sequencing with filter and lambda
    71. [].extend
    72. append vs. extend
    73. split and extend
  11. Tuples
    1. Create tuple
    2. Convert list to tuple and tuple to list
    3. Enumerate returns tuples
    4. Change a tuple
    5. Sort tuples
    6. Sort tuples by specific elements
    7. Sort and secondary sort
  12. Files
    1. File types: Text vs Binary
    2. Open vs. Read vs. Load
    3. Binary files: Images
    4. Reading an Excel file
    5. Reading a YAML file
    6. Read and analyze a text file
    7. Open and read file (easy but not recommended)
    8. Open and read file using with (recommended)
    9. Read file remove newlines
    10. Filename on the command line
    11. Filehandle with return
    12. Read all the lines into a list
    13. Read all the characters into a string (slurp)
    14. Not existing file
    15. Open file exception handling
    16. Open many files - exception handling
    17. Writing to file
    18. Print to file
    19. Append to file
    20. Binary mode
    21. Does file exist? Is it a file?
    22. Direct access of a line in a file
    23. Exercise: count digits
    24. Exercise: remove newlines
    25. Exercise: print lines with Report
    26. Exercise: color selector
    27. Exercise: ROT13
    28. Exercise: Combine lists
    29. Exercise: Number guessing game - save to file
    30. Solution: count numbers
    31. Solution: remove newlines
    32. Solution: print lines with Report
    33. Solution: color selector
    34. Solution: ROT13
    35. Solution: Combine lists
    36. Solution: Combine lists with tuple
    37. Filehandle using with and not using it
  13. Dictionary (hash)
    1. What is a dictionary
    2. When to use dictionaries
    3. Various dictionary examples
    4. Dictionary
    5. Create dictionary
    6. keys
    7. Loop over keys
    8. Loop over dictionary keys
    9. Loop using items
    10. values
    11. Not existing key
    12. Get key
    13. Does the key exist?
    14. Does the value exist?
    15. Delete key
    16. List of dictionaries
    17. Shared dictionary
    18. immutable collection: tuple as dictionary key
    19. immutable numbers: numbers as dictionary key
    20. Sort a dictionary
    21. Sort dictionary values
    22. Sort dictionary by value
    23. Sort dictionary keys by value (another example)
    24. Insertion Order is kept
    25. Change order of keys in dictionary - OrderedDict
    26. Set order of keys in dictionary - OrderedDict
    27. Setdefault
    28. Exercise: count characters
    29. Exercise: count words
    30. Exercise: count words from a file
    31. Exercise: Apache log
    32. Exercise: Combine lists again
    33. Exercise: counting DNA bases
    34. Exercise: Count Amino Acids
    35. Exercise: List of dictionaries
    36. Exercise: Dictionary of dictionaries
    37. Exercise: Age limit with dictionaries
    38. Exercise: Merge files with timestamps
    39. Solution: count characters
    40. Default Dict
    41. Solution: count characters with default dict
    42. Solution: count words (plain)
    43. Solution: count words (defaultdict)
    44. Solution: count words (Counter)
    45. Solution: count words in file
    46. Solution: Apache log
    47. Solution: Apache log using split
    48. Solution: Combine files
    49. Solution: Combine files-improved
    50. Solution: counting DNA bases
    51. Solution: Count Amino Acids
    52. Solution: List of dictionaries
    53. Solution: Dictionary of dictionaries
    54. Solution: Age limit with dictionaries
    55. Solution: Merge files with timestamps
    56. Do not change dictionary in loop
    57. Named tuple (sort of immutable dictionary)
    58. Create dictionary from List
    59. Sort Hungarian letters (lookup table)
  14. Sets
    1. sets
    2. set operations
    3. Creating a set
    4. Creating a set from a list
    5. Converting set to list
    6. Creating an empty set
    7. Adding an element to a set (add)
    8. Merging one set into another set (update)
    9. set intersection
    10. set subset
    11. set symmetric difference
    12. set union
    13. set relative complement (difference)
    14. Set of numbers
    15. Set of lists
    16. Set of tuples
    17. Create set from List
  15. Code Reuse
    1. Permutations
    2. k-Permutations
    3. Binomial coefficient
    4. Binomial coefficient - factorial function
    5. k-Permutations - factorial function
    6. Permutations - factorial funcion
    7. mymath module
    8. Permutations - module
    9. k-Permutations - module
    10. Binomial coefficient - module
  16. Functions (subroutines)
    1. Why use functions?
    2. Defining simple function
    3. Passing positional parameters to a function
    4. Function parameters can be named
    5. Mixing positional and named parameters
    6. Mixing positional and named parameters - order
    7. Default values, optional parameters, optional parameters
    8. Default value in first param
    9. Several defaults, using names
    10. Default list
    11. Arbitrary number of arguments *
    12. Arbitrary number of arguments passing a lists
    13. Arbitrary number of arguments passing a tuple
    14. Fixed parmeters before the others
    15. Pass arbitrary number of functions
    16. Arbitrary key-value pairs in parameters **
    17. Pass a real dictionary
    18. The dictionary contains copy
    19. The dictionary contains copy but NOT deep copy!
    20. Extra key-value pairs in parameters
    21. Extra key-value pairs in parameters for email
    22. Every parameter option
    23. Duplicate declaration of functions (multiple signatures)
    24. Pylint duplicate declaration
    25. Return more than one value
    26. Recursive factorial
    27. Recursive Fibonacci
    28. Non-recursive Fibonacci
    29. Unbound recursion
    30. Set recurions limit
    31. Variable assignment and change - Immutable
    32. Variable assignment and change - Mutable list
    33. Variable assignment and change - Mutabled dict
    34. Parameter passing of functions
    35. Passing references
    36. Function documentation
    37. Sum ARGV
    38. Copy-paste code
    39. Copy-paste code fixed
    40. Copy-paste code further improvement
    41. Palindrome
    42. Exit vs return vs break and continue
    43. Exercise: statistics
    44. Exercise: Pascal's triangle
    45. Exercise: Pascal's triangle functions
    46. Exercise: recursive dependency tree
    47. Exercise: dependency tree
    48. Exercise: Tower of Hanoi
    49. Exercise: Merge and Bubble sort
    50. Exercise: Refactor previous solutions to use functions
    51. Exercise: Number guessing - functions
    52. Solution: statistics
    53. Solution: Pascal triangle
    54. Solution: Pascal triangle functions
    55. Solution: recursive
    56. Solution: Tower of Hanoi
    57. Solution: Merge and Bubble sort
  17. Modules
    1. Goal of having modules
    2. Before modules
    3. Create modules
    4. path to load modules from - The module search path
    5. sys.path - the module search path
    6. Project directory layouts
    7. Flat project directory structure
    8. Absolute path
    9. Relative path
    10. Relative path explained
    11. Submodules
    12. Python modules are compiled
    13. How "import" and "from" work?
    14. Execute at import time
    15. Runtime loading of modules
    16. Conditional loading of modules
    17. What is in our namespace?
    18. Runtime import
    19. Duplicate importing of functions
    20. Duplicate importing of functions - solved
    21. Script or library
    22. Script or library - import
    23. Script or library - from import
    24. Scope of import
    25. Import multiple times
    26. Do not import *
    27. Exercise: Number guessing
    28. Exercies: Scripts and modules
    29. Exercise: Module my_sum
    30. Exercise: Convert your script to module
    31. Exercise: Add doctests to your own code
    32. Solution: Module my_sum
    33. Loaded modules and their path
    34. Built-in modules
  18. Other Modules
    1. assert to verify values
    2. mycalc as a self testing module
    3. doctest
    4. Export import
    5. Export import with all
    6. import module
    7. deep copy list
    8. deep copy dictionary
  19. Python standard modules (standard packages)
    1. Some Standard packages
  20. math
    1. math examples
  21. sys
    1. sys module
    2. Writing to standard error (stderr)
    3. exit prints to STDERR
  22. os
    1. python which OS are we running on (os, platform)
    2. Current directory (getcwd, pwd, chdir)
    3. OS path
    4. os.path.join
    5. Directory listing
    6. Directory listing using glob
    7. Traverse directory tree - list directories recursively
    8. OS dir (mkdir, makedirs, remove, rmdir)
    9. expanduser - handle tilde ~ the home directory of the user
    10. Get process ID
    11. External command with system
    12. Accessing the system environment variables from Python
    13. Set environment variables on the fly
    14. Reading the .env environment file in Python
    15. Set env and run command
  23. Pathlib
    1. Pathlib example
    2. Pathlib cwd
    3. Pathlib get extension (suffix)
    4. Pathlib current file
    5. Pathlib parents (dirname)
    6. Pathlib parts (basename)
    7. Pathlib exists
    8. Pathlib iterdir (flat)
    9. Pathlib mkdir (makedir)
  24. shutil
    1. shutil module
  25. time
    1. time module
    2. sleep in Python
    3. timer
    4. Current date and time datetime now
    5. Converting string to datetime (parsing date and time string)
    6. Parse datetime string with and without timezone information
    7. datetime fromisoformat
    8. date fromisoformat (only date, no time)
    9. datetime arithmeticis (subtract)
    10. Timezone aware datetime
    11. datetime arithmeticis (compare, sort)
    12. datetime arithmeticis (addition)
    13. Rounding datetime object to nearest second (removing microseconds)
    14. Rounding datetime object to date (removing hours, minutes, seconds)
    15. Convert datetime object to date object
    16. Convert datetime object to time object
    17. Today (date)
  26. subprocess
    1. External CLI tool to demo subprocess
    2. Run with os.system
    3. Run external process let STDOUT and STDERR through
    4. Run external process and capture STDOUT and STDERR separately
    5. Run external process and capture STDOUT and STDERR merged together
    6. subprocess in the background
    7. subprocess collect output while external program is running
    8. Exercise: Processes
    9. Subprocess TBD
  27. Command line arguments with argparse
    1. Command line arguments
    2. Modules to handle the command line
    3. argparse
    4. Basic usage of argparse
    5. Positional argument
    6. Many positional argument
    7. Convert to integers
    8. Convert to integer
    9. Named arguments
    10. Boolean Flags
    11. Short names
    12. argparse print help explicitely
    13. Argparse xor - mutual exlucise - only one - exactly one
    14. Argparse argument with default and optional value
    15. Conditional required parameter with argparse
    16. Exercise: Command line parameters
    17. Exercise: argparse positional and named
    18. Other
  28. JSON
    1. JSON - JavaScript Object Notation
    2. JSON dumps
    3. JSON loads
    4. dump
    5. load
    6. Round trip
    7. Pretty print JSON
    8. Serialize Datetime objects in JSON
    9. Sort keys in JSON
    10. Set order of keys in JSON - OrderedDict
    11. Exercise: Counter in JSON
    12. Exercise: Phone book in JSON
    13. Solution: Counter in JSON
    14. Solution: Phone book
  29. YAML
    1. YAML - YAML Ain't Markup Language
    2. Read YAML
    3. Write YAML
    4. Exercise: Counter in YAML
    5. Exercise: Phone book in YAML
    6. Solution: Counter in YAML
  30. Exception handling