programming:python:python
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
programming:python:python [2022/11/30 10:17] – created ateixeira | programming:python:python [2024/07/08 13:42] (current) – [Exercice 4 : for2] ateixeira | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Hello world ! ====== | ====== Hello world ! ====== | ||
- | ===== Exercice 1 : printf | + | ===== Exercice 1 : print ===== |
* Open a terminal | * Open a terminal | ||
Line 21: | Line 21: | ||
</ | </ | ||
+ | ===== Exercice 2 : input ===== | ||
+ | |||
+ | * Open a terminal | ||
+ | * Create your file by writing the following command | ||
+ | <code python> | ||
+ | vim ex2.py | ||
+ | </ | ||
+ | * Enter insertion mode by pressing Insert | ||
+ | * Write the line below | ||
+ | <code python> | ||
+ | |||
+ | prenom = input(' | ||
+ | nom = input(' | ||
+ | |||
+ | print(" | ||
+ | |||
+ | </ | ||
+ | * Then press Esc key | ||
+ | * Save the file | ||
+ | * Execute | ||
+ | < | ||
+ | python3 ex2.py | ||
+ | </ | ||
+ | |||
+ | ===== Exercice 3 : for ===== | ||
+ | |||
+ | * Open a terminal | ||
+ | * Create your file by writing the following command | ||
+ | <code python> | ||
+ | vim ex3.py | ||
+ | </ | ||
+ | * Enter insertion mode by pressing Insert | ||
+ | * Write the line below | ||
+ | <code python> | ||
+ | |||
+ | nombre = input(' | ||
+ | |||
+ | for i in range(int(nombre)): | ||
+ | print(i+1, end=' ') | ||
+ | </ | ||
+ | * Then press Esc key | ||
+ | * Save the file | ||
+ | * Execute | ||
+ | < | ||
+ | python3 ex3.py | ||
+ | </ | ||
+ | |||
+ | ===== Exercice 4 : for2 ===== | ||
+ | |||
+ | * Open a terminal | ||
+ | * Create your file by writing the following command | ||
+ | <code python> | ||
+ | vim ex4.py | ||
+ | </ | ||
+ | * Enter insertion mode by pressing Insert | ||
+ | * Write the line below | ||
+ | <code python> | ||
+ | |||
+ | nombre1 = input(' | ||
+ | nombre2 = input(' | ||
+ | |||
+ | for i in range(int(nombre1), | ||
+ | print(i, end=' | ||
+ | |||
+ | </ | ||
+ | * Then press Esc key | ||
+ | * Save the file | ||
+ | * Execute | ||
+ | < | ||
+ | python3 ex4.py | ||
+ | </ |
programming/python/python.1669803439.txt.gz · Last modified: 2022/11/30 10:17 by ateixeira