Ecrire un programme Python qui demande un nombre nul(n) et qui imprime un triangle de nombre illuté comme-ci: 1 11 111
Informatique
OD08
Question
Ecrire un programme Python qui demande un nombre nul(n) et qui imprime un triangle de nombre illuté comme-ci:
1
11
111
1
11
111
1 Réponse
-
1. Réponse caylus
Réponse :
Bonjour,
Explications :
def triangle_un(p):
...return ([ str(1)*i for i in range(1,p+1) ])
a=5
tr=triangle_un(a)
for i in range(len(tr)):
...print (tr[i])