Beginner · 6h 9m · 22 lessons
Python Basics
Write your first real programs in the friendliest language there is.
What you'll learn
- ✦Run Python two ways: type code straight into the
REPL, or write and run a saved.pyscript - ✦Store data in variables and tell apart the core types:
int,float,str,bool - ✦Build and format text with f-strings and clean it up with string methods like
.strip()and.replace() - ✦Choose the right collection for the job and use it correctly: lists, tuples, dictionaries, and sets
- ✦Branch with
if/elif/elseand repeat work correctly withforandwhileloops, avoiding the classic off-by-one and infinite-loop traps - ✦Write functions with parameters, return values, and default arguments, and explain why a function needs a
returnto hand back a result - ✦Pull in extra power with
import, naming the everyday tools in Python's standard library - ✦Read and write files safely with
with open(...), and catch errors gracefully withtry/exceptinstead of crashing - ✦Write shorter, Pythonic code with comprehensions, slicing,
enumerate, andzip - ✦Install a package with
pip, write a simple class, and convert data to and from JSON
Part of these career paths
- Backend Developer path · course 2 of 14
- CS Foundations path · course 4 of 5
Certification projects
Build 4 projects to earn your certificate
Hands-on work that proves you can apply what you learned — part of the certificate requirements.
Syllabus
Module 1 · 46m
Getting started Free
What you'll be able to do
- Can explain what Python is and why it's a good first language to learn.
- Can type a line into the REPL and read the result it prints back.
- Can save code in a .py file and run it from the terminal with python3.
Module 2 · 1h 11m
Data & types Locked
What you'll be able to do
- Can store a value in a variable and tell == apart from =.
- Can name the type of any value (int, float, str, bool) and convert between them.
- Can build text with f-strings and clean it up with .strip(), .upper(), and .replace().
- Can pick the right arithmetic operator, including // and % for whole-number division and remainders.
Module 3 · 1h 16m
Collections & flow Locked
What you'll be able to do
- Can choose between a list and a tuple, and index into either from the front or the back.
- Can look up and update a dictionary by key, and use a set to keep only unique values.
- Can branch code with if/elif/else and know exactly which single branch runs.
- Can write a for loop over a collection or range(), and a while loop that reliably stops.
Module 4 · 1h 33m
Functions & files Locked
What you'll be able to do
- Can write a function with def, call it, and pass in parameters.
- Can use return to hand back a value, and set a safe default argument.
- Can import a standard-library module and use its functions with the dot.
- Can read and write a file safely with with open(...).
- Can catch a named error with try/except instead of letting the program crash.
Module 5 · 41m
Pythonic data Locked
What you'll be able to do
- Can write a list comprehension to build or filter a list in one line.
- Can slice a list or string with [start:stop] and know which end is excluded.
- Can loop with enumerate() to get an index and a value, or zip() to pair two lists.
Module 6 · 42m
Real-world Python Locked
What you'll be able to do
- Can install a package with pip and explain why a virtual environment keeps projects separate.
- Can write a simple class with __init__ and a method, and create objects from it.
- Can convert Python data to and from JSON text with json.dumps() and json.loads().