Introduction to Python Programming - Basics

September, 2022

A first code

This is a first instance of piece of Python code.

for i in [1,2,3]:
  print("i =", i)
## i = 1
## i = 2
## i = 3
print("End")
## End

Description ?

First calculus

We have the following lines using the usual operations \(+\), \(-\), \(\div\), \(\times\).

5+7
## 12
3+4
## 7

Indentation !

Loops

For Loop

  • The most used
  • Don’t have to be careful with terminaison !
    • Incremental loop
    • End is planified in advance

Slide with Code

This is some code with a print below.

for i in range(1,4) :
  print("i =", i)
## i = 1
## i = 2
## i = 3

Slide with Table

This is a table.

library(knitr)

kable(summary(cars))
speed dist
Min. : 4.0 Min. : 2.00
1st Qu.:12.0 1st Qu.: 26.00
Median :15.0 Median : 36.00
Mean :15.4 Mean : 42.98
3rd Qu.:19.0 3rd Qu.: 56.00
Max. :25.0 Max. :120.00

Slide with Plot

This is a plot.

plot(pressure)

Paul Liautaud
Paul Liautaud
PhD candidate in Statistical & Machine Learning