215k views
16 votes
A python program for the following output using for loop.

Output:


-13

-7

-1

1 Answer

4 votes

Answer:

In Python

for i in range(-13,0,6):

print(i)

Step-by-step explanation:

Required: A program to display the given output

From the program, we observe the following:

The output begins at 13 i.e begin = 13

The output ends at -1 i.e end = 1

And the difference between each output is 6.

i.e.
-1 - (-7) = -7 - (-13) = 6

So, the syntax of the for loop is: (begin, end + 1, difference)

The program explanation goes thus:

This iterates through the -13 to 1 with a difference of 6

for i in range(-13,0,6):

This prints the required output

print(i)

User Joesdiner
by
6.5k points