Computer Applications
Write a short program to print the following series :
1 4 7 10 ……….. 40.
Python Control Flow
3 Likes
Answer
for i in range(1, 41, 3) :
print(i, end = ' ')Output
1 4 7 10 13 16 19 22 25 28 31 34 37 40
Answered By
2 Likes
Related Questions
Rewrite following code fragments using while loops
min = 0 max = num if num < 0 : min = num max = 0 # compute sum of integers from min to max for i in range(min, max + 1): sum += iRewrite 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 += 1