Write a short program to print the following series :1 4 7 10 …40 1 -4 7 -10 ………….. -40

preview_player
Показать описание
Sumita Arora Class 11 computer science chapter conditional and iterative statement type C Q 9||

Website Link :-

Q. Write a short program to print the following series:
(i) 1 4 7 10 ………. 40
(ii) 1 -4 7 -10 ………….. -40

Answer :-

(i)

for i in range(1,41,3):
print(i,end=" , ")

(ii)

for i in range(1,41,3):
if i % 2 == 0 :
print(-i,end=" , ")
else :
print(i,end=" , ")

Output :-

(i)
1 , 4 , 7 , 10 , 13 , 16 , 19 , 22 , 25 , 28 , 31 , 34 , 37 , 40 ,

(ii)
1 , -4 , 7 , -10 , 13 , -16 , 19 , -22 , 25 , -28 , 31 , -34 , 37 , -40 ,
Рекомендации по теме
Комментарии
Автор

Background ke song ki wajah se voice clear nhi ho pa rhi hai

Shivesh_