lundi 31 août 2015

Python: How to figure out the output of these if & else statements?

The code is written below. I'm having trouble understanding what would be the output of these codes if certain numbers were being input.

m = int(input("Enter a number: "))
for n in range(m):
    for k in range(m):
        if (n > k):
            print (" G ", end='')
        elif (n < k):
            print (" L ", end='')
        else:
            print(" E ", end='')
    print(" ")

For example, what would be the output if:

the value input for max is 5 the value input for max is 1 the value input for max is 0

Aucun commentaire:

Enregistrer un commentaire