bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Python

Python

Foundations

Start with Python syntax, variables, control flow, and the core pieces every later lesson depends on.

Lesson 1

Python Tutorial

Python is a popular programming language.

Read lesson →Loading…
Lesson 2

Python Introduction

Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.

Read lesson →Loading…
Lesson 3

Python Getting Started

However, if you want to run Python on your own computer, follow the instructions below.

Read lesson →Loading…
Lesson 4

Python Syntax

Indentation refers to the spaces at the beginning of a code line.

Read lesson →Loading…
Lesson 5

Python Statements

A computer program is a list of "instructions" to be "executed" by a computer.

Read lesson →Loading…
Lesson 6

Python Output / Print

You have already learned that you can use the print() function to display text or output values:

Read lesson →Loading…
Lesson 7

Python Output Numbers

You can also use the print() function to display numbers:

Read lesson →Loading…
Lesson 8

Python Comments

Comments can be used to explain Python code.

Read lesson →Loading…
Lesson 9

Python Variables

Variables are containers for storing data values.

Read lesson →Loading…
Lesson 10

Python - Variable Names

A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume).

Read lesson →Loading…
Lesson 11

Python Variables - Assign Multiple Values

Python allows you to assign values to multiple variables in one line:

Read lesson →Loading…
Lesson 12

Python - Output Variables

The print() function is often used to output variables.

Read lesson →Loading…
Lesson 13

Python - Global Variables

Variables that are created outside of a function (as in all of the examples in the previous pages) are known as global variables.

Read lesson →Loading…
Lesson 14

Python Data Types

In programming, data type is an important concept.

Read lesson →Loading…
Lesson 15

Python Numbers

There are three numeric types in Python:

Read lesson →Loading…
Lesson 16

Python Casting

There may be times when you want to specify a type on to a variable. This can be done with casting. Python is an object-orientated language, and as such it uses classes to define data types, includin…

Read lesson →Loading…
Lesson 17

Python Strings

Strings in python are surrounded by either single quotation marks, or double quotation marks.

Read lesson →Loading…
Lesson 18

Python - Slicing Strings

You can return a range of characters by using the slice syntax.

Read lesson →Loading…
Lesson 19

Python - Modify Strings

Python has a set of built-in methods that you can use on strings.

Read lesson →Loading…
Lesson 20

Python - String Concatenation

To concatenate, or combine, two strings you can use the + operator.

Read lesson →Loading…
Lesson 21

Python - Format - Strings

But we can combine strings and numbers by using f-strings or the format() method!

Read lesson →Loading…
Lesson 22

Python - Escape Characters

To insert characters that are illegal in a string, use an escape character.

Read lesson →Loading…
Lesson 23

Python - String Methods

Python has a set of built-in methods that you can use on strings.

Read lesson →Loading…
Lesson 24

Python Booleans

Booleans represent one of two values: True or False .

Read lesson →Loading…
Lesson 25

Python Operators

Operators are used to perform operations on variables and values.

Read lesson →Loading…
Lesson 26

Python Arithmetic Operators

Arithmetic operators are used with numeric values to perform common mathematical operations:

Read lesson →Loading…
Lesson 27

Python Assignment Operators

Assignment operators are used to assign values to variables:

Read lesson →Loading…
Lesson 28

Python Comparison Operators

Comparison operators are used to compare two values:

Read lesson →Loading…
Lesson 29

Python Logical Operators

Logical operators are used to combine conditional statements:

Read lesson →Loading…
Lesson 30

Python Identity Operators

Identity operators are used to compare the objects, not if they are equal, but if they are actually the same object, with the same memory location:

Read lesson →Loading…
Lesson 31

Python Membership Operators

Membership operators are used to test if a sequence is presented in an object:

Read lesson →Loading…
Lesson 32

Python Bitwise Operators

Bitwise operators are used to compare (binary) numbers:

Read lesson →Loading…
Lesson 33

Python Operator Precedence

Operator precedence describes the order in which operations are performed.

Read lesson →Loading…
Lesson 34

Python Lists

Lists are used to store multiple items in a single variable.

Read lesson →Loading…
Lesson 35

Python - Access List Items

List items are indexed and you can access them by referring to the index number:

Read lesson →Loading…
Lesson 36

Python - Change List Items

To change the value of a specific item, refer to the index number:

Read lesson →Loading…
Lesson 37

Python - Add List Items

To add an item to the end of the list, use the append() method:

Read lesson →Loading…
Lesson 38

Python - Remove List Items

The remove() method removes the specified item.

Read lesson →Loading…
Lesson 39

Python - Loop Lists

You can loop through the list items by using a for loop:

Read lesson →Loading…
Lesson 40

Python - List Comprehension

List comprehension offers a shorter syntax when you want to create a new list based on the values of an existing list.

Read lesson →Loading…
Lesson 41

Python - Sort Lists

List objects have a sort() method that will sort the list alphanumerically, ascending, by default:

Read lesson →Loading…
Lesson 42

Python - Copy Lists

You cannot copy a list simply by typing list2 = list1 , because: list2 will only be a reference to list1 , and changes made in list1 will automatically also be made in list2 .

Read lesson →Loading…
Lesson 43

Python - Join Lists

There are several ways to join, or concatenate, two or more lists in Python.

Read lesson →Loading…
Lesson 44

Python - List Methods

Python has a set of built-in methods that you can use on lists.

Read lesson →Loading…
Lesson 45

Python Tuples

Tuples are used to store multiple items in a single variable.

Read lesson →Loading…
Lesson 46

Python - Access Tuple Items

You can access tuple items by referring to the index number, inside square brackets:

Read lesson →Loading…
Lesson 47

Python - Update Tuples

Tuples are unchangeable, meaning that you cannot change, add, or remove items once the tuple is created.

Read lesson →Loading…
Lesson 48

Python - Unpack Tuples

When we create a tuple, we normally assign values to it. This is called "packing" a tuple:

Read lesson →Loading…
Lesson 49

Python - Loop Tuples

You can loop through the tuple items by using a for loop.

Read lesson →Loading…
Lesson 50

Python - Join Tuples

To join two or more tuples you can use the + operator:

Read lesson →Loading…
Lesson 51

Python - Tuple Methods

Python has two built-in methods that you can use on tuples.

Read lesson →Loading…
Lesson 52

Python Sets

Sets are used to store multiple items in a single variable.

Read lesson →Loading…
Lesson 53

Python - Access Set Items

You cannot access items in a set by referring to an index or a key.

Read lesson →Loading…
Lesson 54

Python - Add Set Items

Once a set is created, you cannot change its items, but you can add new items.

Read lesson →Loading…
Lesson 55

Python - Remove Set Items

To remove an item in a set, use the remove() , or the discard() method.

Read lesson →Loading…
Lesson 56

Python - Loop Sets

You can loop through the set items by using a for loop:

Read lesson →Loading…
Lesson 57

Python - Join Sets

There are several ways to join two or more sets in Python.

Read lesson →Loading…
Lesson 58

Python frozenset

frozenset is an immutable version of a set.

Read lesson →Loading…
Lesson 59

Python - Set Methods

Python has a set of built-in methods that you can use on sets.

Read lesson →Loading…
Lesson 60

Python Dictionaries

Dictionaries are used to store data values in key:value pairs.

Read lesson →Loading…
Lesson 61

Python - Access Dictionary Items

You can access the items of a dictionary by referring to its key name, inside square brackets:

Read lesson →Loading…
Lesson 62

Python - Change Dictionary Items

You can change the value of a specific item by referring to its key name:

Read lesson →Loading…
Lesson 63

Python - Add Dictionary Items

Adding an item to the dictionary is done by using a new index key and assigning a value to it:

Read lesson →Loading…
Lesson 64

Python - Remove Dictionary Items

There are several methods to remove items from a dictionary:

Read lesson →Loading…
Lesson 65

Python - Loop Dictionaries

You can loop through a dictionary by using a for loop.

Read lesson →Loading…
Lesson 66

Python - Copy Dictionaries

You cannot copy a dictionary simply by typing dict2 = dict1 , because: dict2 will only be a reference to dict1 , and changes made in dict1 will automatically also be made in dict2 .

Read lesson →Loading…
Lesson 67

Python - Nested Dictionaries

A dictionary can contain dictionaries, this is called nested dictionaries.

Read lesson →Loading…
Lesson 68

Python Dictionary Methods

Python has a set of built-in methods that you can use on dictionaries.

Read lesson →Loading…
Lesson 69

Python If Statement

Python supports the usual logical conditions from mathematics:

Read lesson →Loading…
Lesson 70

Python Elif Statement

The elif keyword is Python's way of saying "if the previous conditions were not true, then try this condition".

Read lesson →Loading…
Lesson 71

Python Else Statement

The else keyword catches anything which isn't caught by the preceding conditions.

Read lesson →Loading…
Lesson 72

Python Shorthand If

If you have only one statement to execute, you can put it on the same line as the if statement.

Read lesson →Loading…
Lesson 73

Python Logical Operators

Logical operators are used to combine conditional statements. Python has three logical operators:

Read lesson →Loading…
Lesson 74

Python Nested If

You can have if statements inside if statements. This is called nested if statements.

Read lesson →Loading…
Lesson 75

Python Pass Statement

if statements cannot be empty, but if you for some reason have an if statement with no content, put in the pass statement to avoid getting an error.

Read lesson →Loading…
Lesson 76

Python Match

The match statement is used to perform different actions based on different conditions.

Read lesson →Loading…
Lesson 77

Python While Loops

Python has two primitive loop commands:

Read lesson →Loading…
Lesson 78

Python For Loops

A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string).

Read lesson →Loading…
Lesson 79

Python Functions

A function is a block of code which only runs when it is called.

Read lesson →Loading…
Lesson 80

Python Function Arguments

Information can be passed into functions as arguments.

Read lesson →Loading…
Lesson 81

Python *args and **kwargs

By default, a function must be called with the correct number of arguments.

Read lesson →Loading…
Lesson 82

Python Scope

A variable is only available from inside the region it is created. This is called scope .

Read lesson →Loading…
Lesson 83

Python Decorators

Decorators let you add extra behavior to a function, without changing the function's code.

Read lesson →Loading…
Lesson 84

Python Lambda

A lambda function is a small anonymous function.

Read lesson →Loading…
Lesson 85

Python Recursion

Recursion is when a function calls itself.

Read lesson →Loading…
Lesson 86

Python Generators

Generators are functions that can pause and resume their execution.

Read lesson →Loading…
Lesson 87

Python range

The built-in range() function returns an immutable sequence of numbers, commonly used for looping a specific number of times.

Read lesson →Loading…
Lesson 88

Python Arrays

Note: Python does not have built-in support for Arrays, but Python Lists can be used instead.

Read lesson →Loading…
Lesson 89

Python Iterators

An iterator is an object that contains a countable number of values.

Read lesson →Loading…
Lesson 90

Python Modules

Consider a module to be the same as a code library.

Read lesson →Loading…
Lesson 91

Python Datetime

A date in Python is not a data type of its own, but we can import a module named datetime to work with dates as date objects.

Read lesson →Loading…
Lesson 92

Python Math

Python has a set of built-in math functions, including an extensive math module, that allows you to perform mathematical tasks on numbers.

Read lesson →Loading…
Lesson 93

Python JSON

JSON is a syntax for storing and exchanging data.

Read lesson →Loading…
Lesson 94

Python RegEx

A RegEx, or Regular Expression, is a sequence of characters that forms a search pattern.

Read lesson →Loading…
Lesson 95

Python PIP

PIP is a package manager for Python packages, or modules if you like.

Read lesson →Loading…
Lesson 96

Python Try Except

The try block lets you test a block of code for errors.

Read lesson →Loading…
Lesson 97

Python String Formatting

F-String was introduced in Python 3.6, and is now the preferred way of formatting strings.

Read lesson →Loading…
Lesson 98

Python None

None is a special constant in Python that represents the absence of a value.

Read lesson →Loading…
Lesson 99

Python User Input

Python allows for user input.

Read lesson →Loading…
Lesson 100

Python Virtual Environment

A virtual environment in Python is an isolated environment on your computer, where you can run and test your Python projects.

Read lesson →Loading…