CBSE Class 10 Computer Applications Question 20 of 26

Python Conditionals and Loops — Question 11

Back to all questions
11
Question

Question 8(ii)

Write a short program to print the following series :

1 -4 7 -10 .......... -40

Answer
Solution
x = 1
for i in range(1, 41, 3) :
    print(i * x, end = ' ')
    x *= -1
Output
1 -4 7 -10 13 -16 19 -22 25 -28 31 -34 37 -40