Ajout de TP 4
Et un supplément.
This commit is contained in:
parent
798f58ba8f
commit
6813e583bb
7 changed files with 449 additions and 0 deletions
31
S1/TP 4/rebours.py
Normal file
31
S1/TP 4/rebours.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
# PREUD'HOMME BONTOUX Geoffrey - PeiP 12 - 2014/2015
|
||||
# TP n°4 donné le 3/10/2014 - Compte à rebours
|
||||
# http://www.fil.univ-lille1.fr/~wegrzyno/portail/Info/Doc/HTML/tp_iteration_conditionnelle.html
|
||||
|
||||
|
||||
# [Q1] Programmez une procédure nommée compte_a_rebours
|
||||
def compte_a_rebours(depart):
|
||||
"""
|
||||
Affiche le décompte jusque 0 à partir de depart.
|
||||
|
||||
CU : depart entier > 0
|
||||
"""
|
||||
assert(type(depart) is int and depart > 0), \
|
||||
"depart doit être un entier supérieur à 0"
|
||||
|
||||
for i in range(depart, -1, -1):
|
||||
print(i)
|
||||
|
||||
# [Test]
|
||||
# >>> compte_a_rebours(10)
|
||||
# 10
|
||||
# 9
|
||||
# 8
|
||||
# 7
|
||||
# 6
|
||||
# 5
|
||||
# 4
|
||||
# 3
|
||||
# 2
|
||||
# 1
|
||||
# 0
|
Reference in a new issue