
This course includes our updated coding exercises so you can practice your skills as you learn.
See a demo
Introduction to the course: contains important information!
Explore Python's if statements and the ternary operator, using boolean operators and not and or, with examples of raining, temperature, and simple conditions. Learn indentation, elif, and else, plus comments.
Explore Python for loops, iterables, and the range function to iterate sequences with start, end exclusive, and optional steps, and print multiple values.
Explore Python's casting and arithmetic operators, converting between int, float, and str; compare / and // division, modulo, and exponent, using input and string concatenation as examples.
Explore string comparisons in Python, learning the equals operator, case-insensitive checks with lower, and lexicographical ordering using Unicode values. Use ord to get codes and char to convert codes.
Explore Python's match statement as the switch equivalent since Python 3.10, using cases, a default underscore, no breaks, and alternatives with a vertical bar.
Discover how Python supports freestanding functions and how they compare to class methods, while mastering various argument passing techniques; explore how Kotlin inherits Python features.
Learn how to use a variable-length argument list in Python with an asterisk prefix, treating args as a tuple you can iterate over and index.
Learn how Python slicing creates subparts of tuples (and later strings and lists) using start, end, and step, including negative indices, with end-exclusive ranges and default values.
Explore tuple functions and methods in Python using len, max, min, count, and index; see their application to strings and lists and how errors occur with missing indices.
Learn how to apply conditions in Python list comprehensions to filter and transform data. The lecture covers using if filters and if-else expressions to modify words by length, including uppercasing.
Explore Python set functions such as union, intersection, difference, and symmetric difference. Learn how superset works and how the minus operator does the same as difference.
Explore Python dictionaries, the map-like key-value containers, learn to create, access, update, iterate, and delete entries, and see how they compare to Java maps.
Explore removing items from dictionaries using the del operator, pop, and pop item; compare clear versus setting to an empty dictionary, with practical tips on efficiency.
Explore how dictionary views like keys, values, and items offer dynamically updating containers that reflect changes to the dictionary.
Explore Python's defaultdict from collections, learn how it supplies a default value for missing keys (empty string for strings) and prevents a traceback.
Explore how to use Python's re.search to find patterns in text, including capture groups and handling multi-line strings with the DOTALL flag.
Explore Python's regular expression module findall to retrieve all matches in text, using capture groups, literal dots, and multi-line strings, and compare with match and search behavior.
Explore the multi-line flag to match the start and end of each line in a regular expression, using dot star, dot all, and the multi-line option for per-line matches.
Explore compiling regular expressions with re.compile and substituting text with re.sub in strings. Flags are embedded in the compiled pattern, so ignore case works only when included during compile.
Discover how to use Python assertions, including the assert keyword to enforce conditions, trigger assertion errors with custom messages, and optionally catch them with try-except, mirroring Java behavior.
Explore Python constructors by defining __init__ and using self to create attributes. Learn how to pass data, manage arguments, and understand protected and private naming with underscores and dunder methods.
Learn how to convert Python objects to strings by implementing the __str__ method and using str(obj) to obtain the string representation.
Explain Python's __repr__ returns a machine-readable string that can recreate objects, using a format string and repr, and caution about using eval to run such strings.
Explore Python inheritance by extending a person class with an employee subclass and defining go on holiday and eating methods. Constructors are inherited in Python.
Override methods in Python subclasses to customize behavior; extend an animal with a cat that defines meow, and call speak, noting you can't overload by types or numbers.
Explore multiple inheritance in Python by combining a car class with an alarm class and using a mixin to bolt on functionality, while handling self arguments and is-a relationships.
Explore how Python resolves methods in inheritance using the method resolution order (MRO). See how C from A and B selects run via C.MRO, illustrating the diamond problem.
Develop a Python class word that overloads the add operator to concatenate text, enabling w1 plus w2 to yield a new word with combined text.
Create package attributes by placing import statements inside packages and using __init__.py to expose subpackages. Build convenient access to nested modules via from . import mymodule and attribute chaining.
Explore how the Python map function transforms iterables by applying a one-argument function, such as str.lower, to each item and producing a lowercase list of animals.
Explore how Python's with statement ensures automatic resource closure by implementing __enter__ and __exit__ in your classes, mirroring Java's try-with-resources. Use with open('test.txt') as file to read lines.
Learn to write text files in Python using with open in text mode and the write method to create temp.txt. Run python main.py to confirm the file appears.
This course will help you to learn to program in Python by leveraging the skills you already have in Java, or another high-level object-oriented programming language.
I won't waste your time explaining things you already know, like what functions are, or exceptions or classes. Instead, we'll dive right into how to make use of the concepts you already understand in another language, in Python.
We'll start with the most important syntax first, so that after the first section or two you'll already be able to write Python scripts. Then we'll cover how to work with classes, containers, regular expressions and files in Python, and more.
You'll also learn how to use Numpy for numerical computing (less complicated than it sounds!) and how to use Pandas as a virtual spreadsheet. In the final section we'll cover how to draw charts so you can visualise your data, and how to use a simple artificial neural network to make predictions based on your data.
The courses includes suggested exercises and quizzes to help you check your progress. With a little practice, you can quickly learn to make use of Python for automating routine tasks, processing text data, working with numerical data, or whatever you need to do.
If you already have some programming knowledge and don't want to sit through explanations of basic concepts, but do want to learn to use Python alongside your existing programming skills, this course is for you.