Answer to Question #303197 in Python for Abrar

Question #303197

Write the python program, which prints the following sequence of values in loops:

18,-27,36,-45,54,-63


1
Expert's answer
2022-02-27T04:12:15-0500
n = 0
for i in range(0, 6):
    if i%2 == 0:
        n += 18
        print(n, end=',')
    elif i != 5:
        print(n - (2*n) - 9, end=',')
    else:
        print(n - (2*n) - 9)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS