45.9k views
1 vote
Design the logic for a program that outputs every number from 1 through 15.

User Rmeakins
by
7.8k points

1 Answer

4 votes
Another way to think about this is through the use of a loop, since printing a number is a very repetitive task, you could also use,

number = 1
while number < 16:
print(number)
number = number + 1

The logic behind this is the "while" loop would check whether the variable 'number' is less than 16 (i.e. between 1 and 15) if so, it prints the number and then adds one to it. It then repeats the check over and over until 16 is reached and then the program terminates.
User Salva
by
7.6k points