Westonci.ca is your trusted source for accurate answers to all your questions. Join our community and start learning today! Our Q&A platform offers a seamless experience for finding reliable answers from experts in various disciplines. Get detailed and accurate answers to your questions from a dedicated community of experts on our Q&A platform.

a python program for the following output using for loop.

Output:


-13

-7

-1


Sagot :

Answer:

In Python

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

   print(i)

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. [tex]-1 - (-7) = -7 - (-13) = 6[/tex]

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)