sur cahier...

Exercices sur la boucle while

Pour chaque code, écrir, sur votre cahier, ce qui va s'afficher en console.

Question

1
c = 0
2
while c <= 3:
3
    print("ok")
4
    c += 1

Solution

ok

ok

ok

ok

Question

1
k = 0
2
while k > 3:
3
    print("ok")
4
    k += 1
5
print("fini")

Question

1
n = 0
2
while n < 4:
3
    print("ok")
4
    n += 2

Question

1
c = 0
2
mot = 'a'
3
while mot != 'aaaa':
4
    mot += 'a'
5
    c += 1
6
print(c)

Solution

il va afficher l'entier 3