Python

An easy-to-read language used for data analysis and AI. Take the lessons in order; each one has a short explanation, runnable examples and practice with instant checking.

Baccalaureate Lessons marked “Baccalaureate” cover the 2nd-year Baccalaureate curriculum.

Getting started

  1. 1Your first program: print and commentsPrint text, numbers and calculation results, tell text from numbers, and leave comments with #.Baccalaureate
  2. 2Calculations and textUse every Python arithmetic operator, know the order they run in, tell numbers from text, and join them in one sentence.Baccalaureate
  3. 3VariablesStore values in clearly named variables, change them, and use them in calculations and printing.Baccalaureate

Making decisions

  1. 4The if statementMake a program run commands only when a condition holds, using if, indentation and the == comparison.Baccalaureate
  2. 5if - else and comparison operatorsChoose between two paths with if - else, and compare values: equal, not equal, greater, less.Baccalaureate
  3. 6elif chainsChoose between more than two paths with an if, elif, else chain, and put the conditions in the right order.Baccalaureate
  4. 7Logical operators: and, orJoin two conditions into one with and when both must be true, and with or when one is enough.Baccalaureate
  5. 8The bool typeUse True and False in variables and if conditions, and save the result of a condition to use later.Baccalaureate
  6. 9Nested conditions and countingPut an if inside another if, tell which else belongs where from the indentation, and increase a counter inside a condition.Baccalaureate

Loops

  1. 10Repeating with forRepeat code a set number of times with for and range(), and control the start, stop and step.Baccalaureate
  2. 11Repeated calculationsAdd and multiply many numbers with a for loop, use the loop variable in the calculation, shorten with +=, and check with if inside the loop.Baccalaureate
  3. 12for loops over lists and textUse a for loop to go through values written in square brackets, or through the letters of a text, one by one.Baccalaureate

Functions

  1. 13Built-in functions and importUse ready-made functions such as round, max, min, abs and len, and import math and random to round, calculate and make random numbers.Baccalaureate
  2. 14Defining functions with defCreate your own function with def, a parameter and return, call it, and know where its variables can be used.Baccalaureate
  3. 15Functions in practiceWrite functions with several arguments or none, put if and for inside them, and turn a flowchart into code.Baccalaureate

Lists and arrays

  1. 16ListsStore many values in one variable, pick them out by position, and add them up with a for loop.Baccalaureate
  2. 17Arrays: array and numpyCreate an array of whole numbers with the array library and read its values, and meet numpy arrays that calculate on every value at once.Baccalaureate
  3. 18Lists with loopsUse a for loop with a list to find the total and average, count values that match a condition, find the largest value yourself, and build a new list with append.Baccalaureate