Foundation · PY-101 · Python Academy

Python Core: learn Python by running it

Every Python fundamental in one course: basics, control flow, functions, collections, strings, files, errors, modules, OOP, generators and testing. Each topic comes alive, then you practise it live.

  • Free
  • Beginner friendly
  • 60 lessons
  • 300 questions
  • No install needed
  • 🏆 Certificate

Updated December 2026 · Python 3 · English · by Suthahar Jegatheesan

What you'll learn

  • Write, run and debug Python programs with confidence
  • Control flow with conditions and loops, and write reusable functions
  • Choose and use lists, tuples, sets and dictionaries, including comprehensions
  • Read and write files, handle errors and organise code into modules
  • Model real things with classes, inheritance and dataclasses
  • Use iterators, generators, decorators and type hints, and test your code with pytest

Try it right now

This is the editor you get in every lesson. Press Run.

main.py
Output
Press Run to see the output. Python runs in your browser.

Who this course is for

Complete beginners

Never written a line of code? Lesson 1 starts at zero.

AI tool users

You use ChatGPT or Copilot to write Python and want to understand what it gives you.

Students

School, college or university: build the base for data, AI and software jobs.

Career changers

Testers, analysts and admins adding automation to their work.

Course curriculum

Every lesson has the same flow: a 30-second answer, then Try it (live code, visualiser and a challenge), a story, an explanation, a pro tip and a quiz.

14 modules · 60 lessons · 300 practice questions

Module 1: Getting started with Python

3 lessons · 0 done
  1. What is Python? Python is a general-purpose programming language that reads almost like plain English. Watch it come alive Live code Challenge 5-question quiz
  2. print() and your first program print() is the built-in Python function that shows values on the screen. Watch it come alive Live code Challenge 5-question quiz
  3. Comments A comment is text in your code that Python ignores. Watch it come alive Live code Challenge 5-question quiz

Module 2: Variables and data types

3 lessons · 0 done
  1. Variables A variable is a name that points to a value, such as age = 25. Watch it come alive Live code Challenge 5-question quiz
  2. Data types A data type tells Python what kind of value something is and what you can do with it. Watch it come alive Live code Challenge 5-question quiz
  3. Type conversion Type conversion, also called casting, turns a value into another type with int(), float(), str() or bool(). Watch it come alive Live code Challenge 5-question quiz

Module 3: Operators

2 lessons · 0 done
  1. Arithmetic operators Arithmetic operators do maths on numbers: + - * and / work as you expect, // divides and drops the remainder, % gives the remainder, and ** raises to a power. Watch it come alive Live code Challenge 5-question quiz
  2. Comparison and logical operators Comparison operators such as ==, !=, < and >= compare two values and give True or False. Watch it come alive Live code Challenge 5-question quiz

Module 4: Strings and input

2 lessons · 0 done
  1. Strings and f-strings A string is text, stored as a sequence of characters you can index and slice. Watch it come alive Live code Challenge 5-question quiz
  2. User input and Lab 01: Calculator input() pauses the program, shows a prompt and returns what the user typed, always as a string. Watch it come alive Live code Challenge 5-question quiz

Module 5: Conditions

3 lessons · 0 done
  1. if, elif and else An if statement runs a block of code only when its condition is True. Watch it come alive Live code Challenge 5-question quiz
  2. Nested conditions A nested condition is an if inside another if, so the inner check only happens when the outer one is True. Watch it come alive Live code Challenge 5-question quiz
  3. match statements A match statement compares one value against a list of case patterns and runs the first one that fits. Watch it come alive Live code Challenge 5-question quiz

Module 6: Loops

4 lessons · 0 done
  1. for loops and range() A for loop runs a block once for each item in a sequence, such as a list, a string or a range of numbers. Watch it come alive Live code Challenge 5-question quiz
  2. while loops A while loop repeats its block as long as its condition is True, checking before every round. Watch it come alive Live code Challenge 5-question quiz
  3. break, continue and loop else break ends a loop immediately, continue skips the rest of the current round and goes to the next one. Watch it come alive Live code Challenge 5-question quiz
  4. Nested loops A nested loop is a loop inside another loop: for every round of the outer loop, the inner loop runs all the way through. Watch it come alive Live code Challenge 5-question quiz

Module 7: Functions

7 lessons · 0 done
  1. Defining functions A function is a named block of code you can run whenever you need it, by calling its name with brackets. Watch it come alive Live code Challenge 5-question quiz
  2. Parameters and return values Parameters are the names in a function's brackets that receive the values you pass in, called arguments. Watch it come alive Live code Challenge 5-question quiz
  3. Default and keyword arguments A default value makes a parameter optional: def greet(name, greeting="Hello"): uses "Hello" unless you pass something else. Watch it come alive Live code Challenge 5-question quiz
  4. *args and **kwargs *args collects any number of extra positional arguments into a tuple, and **kwargs collects any number of keyword arguments into a dictionary. Watch it come alive Live code Challenge 5-question quiz
  5. Scope Scope is where a variable can be seen. Watch it come alive Live code Challenge 5-question quiz
  6. Lambda functions A lambda is a small, unnamed function written in one line: lambda x: x * 2 takes x and returns x * 2. Watch it come alive Live code Challenge 5-question quiz
  7. Recursion Recursion is when a function calls itself to solve a smaller version of the same problem. Watch it come alive Live code Challenge 5-question quiz

Module 8: Collections

7 lessons · 0 done
  1. Lists A list is an ordered collection of values in square brackets, such as ["tea", "milk"]. Watch it come alive Live code Challenge 5-question quiz
  2. Tuples A tuple is an ordered group of values in round brackets, such as (12.97, 77.59), that cannot be changed after it is made. Watch it come alive Live code Challenge 5-question quiz
  3. Sets A set is an unordered collection of unique values in curly brackets, such as {"tea", "milk"}. Watch it come alive Live code Challenge 5-question quiz
  4. Dictionaries A dictionary stores values under unique keys, written as {"name": "Asha", "age": 29}. Watch it come alive Live code Challenge 5-question quiz
  5. Comprehensions A comprehension builds a new list, dict or set from another collection in one line: [x * 2 for x in nums]. Watch it come alive Live code Challenge 5-question quiz
  6. Unpacking Unpacking assigns the items of a sequence to several variables at once: name, age = ("Asha", 29). Watch it come alive Live code Challenge 5-question quiz
  7. Sorting and searching sorted(items) returns a new sorted list, while items.sort() sorts the list in place. Watch it come alive Live code Challenge 5-question quiz

Module 9: Strings in depth

4 lessons · 0 done
  1. String methods String methods are built-in tools you call on any string with a dot, such as text.split() or name.startswith("Dr"). Watch it come alive Live code Challenge 5-question quiz
  2. Formatting numbers and dates Inside an f-string, a colon after a value adds a format spec: f"{price:,.2f}" gives 1,499.50 and f"{rate:.1%}" gives 12.5%. Watch it come alive Live code Challenge 5-question quiz
  3. Slicing patterns A slice takes part of a string or list with [start:stop:step]. Watch it come alive Live code Challenge 5-question quiz
  4. Regular expressions basics A regular expression is a pattern that describes text, like \d+ for "one or more digits". Watch it come alive Live code Challenge 5-question quiz

Module 10: Files and errors

5 lessons · 0 done
  1. Reading and writing files open(name, mode) opens a file: "w" writes (replacing what was there), "a" appends to the end and "r" reads. Watch it come alive Live code Challenge 5-question quiz
  2. with and context managers A with statement runs a block of code inside a context manager, which sets something up at the start and always cleans it up at the end, even if an error happens. Watch it come alive Live code Challenge 5-question quiz
  3. CSV and JSON CSV stores rows and columns as text with commas, like a spreadsheet, and Python's csv module reads and writes it. Watch it come alive Live code Challenge 5-question quiz
  4. try, except and finally try runs code that might fail; if it raises an exception, the matching except block handles it instead of the program crashing. Watch it come alive Live code Challenge 5-question quiz
  5. Raising and custom exceptions raise stops a function and signals a problem, such as raise ValueError("amount must be positive"). Watch it come alive Live code Challenge 5-question quiz

Module 11: Modules and packages

4 lessons · 0 done
  1. import and from import brings a module into your program, and you use its contents with a dot: import math, then math.sqrt(16). Watch it come alive Live code Challenge 5-question quiz
  2. The standard library tour The standard library is the large set of modules that comes with Python, so you can use them without installing anything. Watch it come alive Live code Challenge 5-question quiz
  3. pip and virtual environments pip installs packages from PyPI, such as pip install requests. Watch it come alive Live code Challenge 5-question quiz
  4. if __name__ == "__main__" Every Python file has a built-in variable __name__. Watch it come alive Live code Challenge 5-question quiz

Module 12: Object-oriented Python

8 lessons · 0 done
  1. Classes and objects A class is a blueprint that describes a kind of thing, and an object is one actual thing made from that blueprint. Watch it come alive Live code Challenge 5-question quiz
  2. __init__ and attributes __init__ is a special method that runs automatically when an object is created, and it sets up the object's attributes. Watch it come alive Live code Challenge 5-question quiz
  3. Methods A method is a function defined inside a class. Watch it come alive Live code Challenge 5-question quiz
  4. Inheritance Inheritance lets a new class (the child) start from an existing class (the parent) and get all its attributes and methods, written class Child(Parent):. Watch it come alive Live code Challenge 5-question quiz
  5. Polymorphism Polymorphism means different classes can be used the same way because they share a method name, even though each does its own thing. Watch it come alive Live code Challenge 5-question quiz
  6. Encapsulation Encapsulation means an object protects its own data and only lets the outside change it in controlled ways. Watch it come alive Live code Challenge 5-question quiz
  7. Dunder methods Dunder methods are special methods with double underscores, like __str__ or __eq__, that Python calls for you in certain situations. Watch it come alive Live code Challenge 5-question quiz
  8. Dataclasses A dataclass is a class mainly for holding data, created with the @dataclass decorator. Watch it come alive Live code Challenge 5-question quiz

Module 13: Advanced Python

4 lessons · 0 done
  1. Iterators An iterable is anything you can loop over, such as a list or a string. Watch it come alive Live code Challenge 5-question quiz
  2. Generators A generator is a function that uses yield instead of return. Watch it come alive Live code Challenge 5-question quiz
  3. Decorators A decorator is a function that takes another function and returns a new function that adds something before or after it, such as logging or a permission check. Watch it come alive Live code Challenge 5-question quiz
  4. Type hints Type hints are optional notes that say what type a value should be, such as def total(prices: list[float]) -> float:. Watch it come alive Live code Challenge 5-question quiz

Module 14: Testing and debugging

4 lessons · 0 done
  1. Reading tracebacks A traceback is the report Python prints when an error stops your program. Watch it come alive Live code Challenge 5-question quiz
  2. Debugging step by step Debugging is finding where the program's real behaviour first differs from what you expected. Watch it come alive Live code Challenge 5-question quiz
  3. assert assert condition, "message" checks that a condition is True and raises AssertionError with your message if it is False. Watch it come alive Live code Challenge 5-question quiz
  4. pytest basics pytest is Python's most popular testing tool: you write functions whose names start with test_, put plain asserts inside, and run pytest to execute them all and report which pass. Watch it come alive Live code Challenge 5-question quiz

How you'll learn

Six ways to learn and check yourself, all free and all in your browser.

Live code

Every example is real Python 3 you can edit and run. No install, nothing leaves your browser.

Code comes alive

Every example plays as an animation: variables are jars, loops spin, functions are machines.

Challenges

A small task at the end of every lesson. Hidden tests tell you if you got it right.

Game lab

Steer a robot through mazes with Python. Each level needs one new idea.

Quizzes

Five questions after each lesson, with the reason behind every answer.

Practice exam

50 random questions, 60 minutes, explained afterwards.

Game lab: Robot Maze Write Python to get a robot to the flag. 5 levels, from your first function call to while loops with if/else. Play now →

Recommended learning sequence

  1. Step 1Read the answerEach lesson opens with a 30-second answer.
  2. Step 2Run itRun the example, change it, break it, fix it.
  3. Step 3Watch itSee the code come alive, line by line.
  4. Step 4Prove itSolve the challenge. The tests check your code.
  5. Step 5Pass the quiz4 of 5 right and the lesson is complete.
  6. Step 6Sit the examAim for 70% or more.
  7. Step 7Get your certificateDownload it as PDF and add it to LinkedIn.

Frequently asked questions

Is PY-101 Python Core free?

Yes. All 60 lessons, the live editor, the visualiser, the challenges, the game lab and the practice exam are free. No account is needed.

How long does PY-101 take?

About 8 to 40 hours: 60 lessons of roughly 8 minutes, plus the game lab and the practice exam. Twenty minutes a day finishes it in two to three weeks.

Do I need to install Python for PY-101?

No. Every lesson runs real Python 3 in your browser using Pyodide (CPython compiled to WebAssembly). Install Python from python.org later, when you build programs on your own computer.

Is the Python Core Certificate an official certification?

No. PY-101, AI-601, GD-301 and the other codes here are MSDEVBUILD course codes. They are not official Microsoft or Python Software Foundation certifications. It shows you finished the path and passed its practice exam.

What comes after Python Core?

Pick a roadmap: AI (data analytics, machine learning, AI agents), Developer (APIs, full-stack), Data, or Automation & Cloud. Every roadmap starts from Python Core.

Ready when you are

Lesson 1 takes about ten minutes. Your progress is saved in this browser as you go.

Start learning