CBSE Class 10 Computer Applications Question 18 of 26

Python Conditionals and Loops — Question 9

Back to all questions
9
Question

Question 7(b)

Rewrite following code fragments using while loops

for i in range(1, 16) : 
    if i % 3 == 0 : 
        print i 
Answer
i = 1
while i < 16:
    if i % 3 == 0 :
        print (i)
    i += 1