
This course includes our updated coding exercises so you can practice your skills as you learn.
See a demo
Explore Python internals, unit testing, and best practices to become a better Python developer, from built-in functions like map, reduce, enumerate, and accumulate to creating generators and decorators with closures.
Explore Python's zip function, learning how it pairs iterables—lists, dictionaries, and strings—into an iterator of tuples, which stops at the shortest input for parallel iteration.
Explore the zip_longest function, which handles lists of different lengths by padding missing elements with a fillvalue, as shown with countries, capitals, and cities and a configurable default.
Solution to the first coding exercise
Learn how the enumerate function adds a counter to an iterable and returns an enumerate object for loops, with a start index to map fruits like apple and pineapple.
Learn how lambda functions, or anonymous functions, work in Python, using the concise lambda syntax for single expressions; explore multi-parameter lambdas and common pitfalls like late binding.
Explore the difference between sort and sorted, and learn how to sort lists in place or sort any iterable using a key and reverse options, including lambda-based sorting.
Learn to order words by length and, for equal lengths, by right-to-left lexicographic order. Implement a two-line Python function using a length-based dictionary and reversed-string sorting.
Explore how the map function applies a function to each item in a collection, replacing loops with concise Python code using lambdas or def functions to capitalize fruits.
Discover how the filter function creates an iterator to select elements that satisfy a condition, using a lambda function on lists and dictionaries with practical examples.
Write a three-line Python function that finds anagrams of a given word from a list by sorting letters and filtering those with the same sorted letters.
Explore the xor operation, its truth table, and how to implement exclusive or in Python using map and zip over two lists of 0s and 1s.
Explore the difference between iterables and iterators, learn how to convert an iterable to an iterator, and implement a custom iterator with __iter__ and __next__ using a powers-of-two example.
Learn how generators simplify creating iterators with yield, enabling memory-efficient sequences like powers of two and infinite streams, and how generator expressions support pipelined computations.
Create an infinite prime-number generator using a naive divisibility test and time each prime, then plot primes versus calculation time, underscoring their role in cryptography and internet security.
Explore the any and all functions in Python, learn their truth conditions on non-empty and empty iterables, and apply them with map and lambda on fruit examples.
Create closures by defining a nested function that captures an enclosing variable and returns the inner function. Use nonlocal to modify that variable, enabling data hiding and supporting decorators.
Welcome to Learn Python by doing!
Tired of the same Python course teaching you data types and printing the same message in a for loop? It's time to learn exciting things!
In this course, you will learn a lot of built in functionalities for you to become a better Python developer. You will also learn how to implement best practices and some unit testing. Some of the things that you will learn in this course are:
The zip function, the map function, the reduce function (with lots of exercises, obviously!)
Virtual environments, dependency management, deterministic builds, dependency resolution and more!
How to implement your own iterators and generators
How to sort things like a pro
Learn about closures (which is a concept that is not specific to Python)
Learn about decorators and some useful ones that come with Python
Sets and why are they cool (with fun exercises)
TDD and unit testing with Pytest
And more! Also, you will be asked to do some interesting exercises along the way, so you reinforce what you learn in this course.
Have fun and enjoy!