Computer Applications
Write a short program to print the following series :
1 -4 7 -10 ………. -40
Python Control Flow
2 Likes
Answer
x = 1
for i in range(1, 41, 3) :
print(i * x, end = ' ')
x *= -1Output
1 -4 7 -10 13 -16 19 -22 25 -28 31 -34 37 -40
Answered By
1 Like
Related Questions
Rewrite following code fragment using while loops :
for i in range(1, 16) : if i % 3 == 0 : print (i)Write a short program to print the following series :
1 4 7 10 ……….. 40.
Predict the output of the following code fragments:
count = 0 while count < 10: print ("Hello") count += 1Predict the output of the following code fragments:
x = 10 y = 0 while x > y: print (x, y) x = x - 1 y = y + 1