User Tools

Site Tools


programming:python:python

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
programming:python:python [2022/11/30 10:37] ateixeiraprogramming:python:python [2022/11/30 12:41] ateixeira
Line 56: Line 56:
 <code python> <code python>
  
-nombre = input('Salut!\nEntre un nombre\n')+nombre = input('Salut!\nEntre un nombre')
  
 for i in range(int(nombre)): for i in range(int(nombre)):
-    print(i+1) +    print(i+1, end=' ')
 </code> </code>
   * Then press Esc key   * Then press Esc key
Line 67: Line 66:
 <code> <code>
 python3 ex3.py python3 ex3.py
 +</code>
 +
 +===== Exercice 4 : for2 =====
 +
 +  * Open a terminal
 +  * Create your file by writing the following command
 +<code python>
 +vim ex4.py
 +</code>
 +  * Enter insertion mode by pressing Insert
 +  * Write the line below
 +<code python>
 +
 +nombre1 = input('Salut!\nEntre un premier nombre\n')
 +nombre2 = input('Et un deuxième nombre: ')
 +
 +for i in range(int(nombre1), int(nombre2) - int(1), -1)):
 +    print(i, end='\n')
 +
 +</code>
 +  * Then press Esc key
 +  * Save the file
 +  * Execute 
 +<code>
 +python3 ex4.py
 </code> </code>
programming/python/python.txt · Last modified: 2024/07/08 13:42 by ateixeira