12 modules

Python tutorial for beginners: learn Python step by step

This Python tutorial starts with installing Python and using the REPL and ends with a tested, working command-line application. Its 12 modules cover data types and control flow, lists, dictionaries and comprehensions, functions and closures, modules, files, CSV and JSON, error handling and logging, object-oriented Python, generators, decorators and type hints, concurrency with threads and asyncio, databases, regular expressions and REST APIs, and automated testing with unittest and pytest.

Who this Python course is for

Complete beginners can follow it from module 1, because Python's readable syntax makes it one of the easiest languages to start with. Students preparing for placements, data or backend roles can use the later modules on functions, OOP, generators, decorators and concurrency, which are frequent interview topics.

How to get the most out of it

Run every example in the Webhise online compiler and experiment with it. Python rewards curiosity: try a list comprehension, then rewrite it as a loop; call a function with different arguments; break something on purpose and read the traceback. The three-part capstone, a course progress tracker built with dataclasses, JSON storage and a command-line interface, gives you a complete project to show.

Course outline

  1. Module 1. Getting Started with Python

    What Python is and how it runs, installing Python and using the REPL, print() and comments, variables and dynamic typing, and reading input.

  2. Module 2. Data Types and Operators

    Numbers and arithmetic, strings and slicing, booleans and logical operators, type conversion, and formatting output with f-strings.

  3. Module 3. Control Flow

    Making decisions with if/elif/else and match, repeating work with while and for loops, range, enumerate and zip, and controlling loops with break, continue and loop else.

  4. Module 4. Data Structures

    Storing groups of values with lists, tuples, dictionaries and sets, unpacking, and building collections concisely with comprehensions.

  5. Module 5. Functions

    Defining functions and returning values, flexible arguments with defaults, keywords, *args and **kwargs, scope and closures, lambdas and key functions, and recursion.

  6. Module 6. Modules, Files and Data Formats

    Organising code into modules and packages, virtual environments and pip, reading and writing files with pathlib, CSV and JSON data, and working with dates, times and time zones.

  7. Module 7. Errors, Debugging and Logging

    Handling exceptions with try/except/else/finally, raising and defining custom exceptions, reading tracebacks and debugging with pdb, and recording what programs do with the logging module.

  8. Module 8. Object-Oriented Python

    Classes and objects, encapsulation with properties, inheritance and super(), special methods and polymorphism, dataclasses and abstract base classes.

  9. Module 9. Advanced Python Features

    Iterators and generators, decorators, context managers, type hints with mypy, and the collections, itertools and functools power tools.

  10. Module 10. Concurrency and Async

    I/O-bound versus CPU-bound work, threads and ThreadPoolExecutor, the GIL and multiprocessing, asyncio coroutines and the event loop, and practical async patterns: TaskGroup, timeouts, semaphores and queues.

  11. Module 11. Databases, Web and Text

    Regular expressions for text processing, SQL databases with sqlite3, parameterised queries and transactions, calling HTTP JSON APIs with urllib, and building a small REST API.

  12. Module 12. Testing and Capstone Project

    Automated testing with unittest and pytest, then a three-part capstone: designing, building and testing a course progress tracker with dataclasses, JSON storage, reports and a command-line interface.

Frequently asked questions

Is Python good for beginners?
Yes. Python reads almost like English, needs very little boilerplate, and lets you see results quickly, which is why it is often the first language taught in schools and colleges.
What does this Python tutorial cover?
Twelve modules: getting started, data types and operators, control flow, data structures, functions, modules, files and data formats, errors, debugging and logging, object-oriented Python, advanced features, concurrency and async, databases, web and text, and testing with a capstone project.
Do I need to install Python?
Not to begin. You can run every example in the Webhise online compiler. Module 1 also shows how to install Python and use the REPL on your own computer.
Which Python topics come up in interviews?
Data types and mutability, lists versus tuples, dictionaries and sets, comprehensions, *args and **kwargs, decorators, generators, OOP, exception handling, and the GIL with threading versus multiprocessing.

More tutorials

Start the python tutorial

Sign in to Webhise for every lesson and example, plus coding practice and the online compiler.