Tous les cours
Débutant 18 hours Gratuit

Python Basics: From Zero to Code

Learn Python from scratch: syntax, variables, strings, operators, control flow, collections, functions and the standard library. Perfect for beginners with no programming experience.

Badge du cours Python Basics Termine toutes les leçons pour le gagner.
Python Basics: From Zero to Code

Contenu du cours

Module 1

Getting started

5 leçons
1

Introduction to Python

What Python is, what it's used for, how to install it and how to run your first program.

20 min Gratuit
2

Syntax, output and comments

The basic rules for writing Python: indentation, statements, how to display text and numbers with print() and how to comment your code.

25 min Gratuit
3

Variables

How to create variables, the rules for naming them, assigning several values at once, printing them, and the difference between local and global variables.

30 min Gratuit
4

Data types and numbers

The data types built into Python, how to check a value's type, and an in-depth look at the three numeric types: int, float and complex.

30 min Gratuit
5

Casting and user input

Convert values between types with int(), float() and str(), and ask the user for data with input() to build interactive programs.

30 min Gratuit
Module 2

Strings

4 leçons
6

Strings: the basics

How to create text in Python, multiline strings, accessing each character, measuring length and searching for words inside a text.

25 min Gratuit
7

Slicing and modifying strings

Extract parts of a text with slicing, use negative indexes and transform strings with upper(), lower(), strip(), replace() and split().

25 min Gratuit
8

Concatenation, f-strings and escape characters

Join text with +, insert variables and expressions with f-strings, control decimals and use escape characters for quotes, line breaks and tabs.

30 min Gratuit
9

String methods

The methods Python provides to transform, search, validate, align, split and join text, with a complete reference table.

35 min Gratuit
Module 3

Booleans and operators

4 leçons
10

Booleans

The values True and False, how comparisons produce them, which values Python treats as true or false, and how to use them to make decisions.

20 min Gratuit
11

Arithmetic and assignment operators

What an operator is, Python's seven math operations and the shortcuts for updating variables like += and -=, including the walrus operator.

25 min Gratuit
12

Comparison, logical, identity and membership operators

Compare values, combine conditions with and, or and not, tell == apart from is, and look for items with in.

30 min Gratuit
13

Bitwise, ternary and operator precedence

Work directly with a number's bits, write one-line decisions with the ternary operator and understand the order in which Python evaluates an expression.

30 min Gratuit
Module 4

Control flow

4 leçons
14

Conditionals: if, elif and else

Make your program decide with if, elif and else, combine conditions, nest decisions and learn the short forms and the pass statement.

30 min Gratuit
15

The match statement

Compare a value against several cases with match and case: the default case, several values per case, extra conditions and tuple patterns.

20 min Gratuit
16

While loops

Repeat code while a condition holds, avoid infinite loops and control the loop with break, continue and else.

25 min Gratuit
17

For loops and range()

Loop through lists and text with for, generate number sequences with range(), and use break, continue, else and nested loops.

30 min Gratuit
Module 5

Data collections

8 leçons
18

Lists: creating and accessing

What a list is, its characteristics, how to create it, measure it and read its items with indexes and ranges, and how it compares to Python's other collections.

25 min Gratuit
19

Lists: changing, adding and removing

Change items or ranges in a list, add with append(), insert() and extend(), and remove with remove(), pop(), del and clear().

25 min Gratuit
20

Lists: looping and comprehensions

The different ways to loop through a list with for and while, and how to create new lists in a single line with list comprehensions.

30 min Gratuit
21

Lists: sorting, copying, joining and methods

Sort lists with sort() and sorted(), copy them without surprises, join them, learn every list method and understand how lists relate to arrays.

35 min Gratuit
22

Tuples

Ordered collections that can't be changed: how to create them, access, 'update', unpack, loop through and join them, and their two methods.

30 min Gratuit
23

Sets and frozensets

Unordered collections without duplicates: how to create them, add and remove items, loop through them, combine them with union, intersection and difference, and the immutable frozenset.

35 min Gratuit
24

Dictionaries: creating, accessing and changing

Store data as key-value pairs: create dictionaries, read values with [] and get(), get keys and values, and change, add and remove items.

30 min Gratuit
25

Dictionaries: looping, copying, nesting and methods

Loop through keys, values and pairs, copy dictionaries safely, organize data in nested dictionaries and learn every method plus dict comprehensions.

35 min Gratuit
Module 6

Functions

5 leçons
26

Functions and arguments

Create your own functions with def, pass them arguments, use default values and keyword arguments, and return results with return.

35 min Gratuit
27

*args, **kwargs and scope

Functions that accept any number of arguments, positional-only and keyword-only arguments, and where each variable lives: local, global and nonlocal scope.

35 min Gratuit
28

Lambda functions and recursion

Write one-line functions with lambda, use them with sorted(), map() and filter(), and solve problems with functions that call themselves.

35 min Gratuit
29

Decorators

Add behavior to a function without changing it: functions as values, the @ syntax, decorators with arguments, return values, functools.wraps and stacked decorators.

35 min Gratuit
30

Iterators and generators

What happens inside a for loop: iterables, iterators, iter() and next(), how to build your own iterator, and generators with yield to produce values on demand.

35 min Gratuit
Module 7

Tools and the standard library

7 leçons
31

Error handling: try and except

Keep your program from stopping on an error: catch exceptions with try and except, tell error types apart, use else and finally, and raise your own errors with raise.

30 min Gratuit
32

None and advanced string formatting

The None value for representing the absence of a value, and every formatting option: thousands separators, percentages, alignment, padding and the format() method.

30 min Gratuit
33

Modules and math

Organize your code into modules, import them in different ways, explore Python's built-in modules and use the math functions and the math module.

30 min Gratuit
34

Dates and times

Work with dates using the datetime module: get the current date, create dates, format them with strftime(), parse them from text and do math with timedelta.

30 min Gratuit
35

JSON

The standard format for exchanging data: turn JSON into Python with loads(), Python into JSON with dumps(), make it readable and save it to or read it from files.

25 min Gratuit
36

Regular expressions

Search, validate and replace text patterns with the re module: findall, search, split and sub, metacharacters, special sequences, sets and the Match object.

40 min Gratuit
37

PIP and virtual environments

Install third-party libraries with pip, save your project's dependencies in requirements.txt and isolate each project in its own virtual environment.

30 min Gratuit

Construisez votre présence numérique

Commencez aujourd’hui : écrivez-nous, nous répondons en moins de 24 heures.