What is the output of the below Python Program?

Question
  1. x = 1
  2. while True:
  3.     if x % 5 = = 0:
  4.         break
  5.     print(x)
  6.     x + = 1
in progress 0
TheDataMonk 55 years 2 Answers 665 views Grand Master -1

Answers ( 2 )

  1. 1
    2
    3
    4

    x +=1 will keep on incrementing unless x%5 == 0 becomes TRUE. It will happen only when x is 5

  2. 1
    2
    3
    4

    loop breaks when x is at 5 and we come out of the while loop (hence it would not be printed).

Leave an answer

Browse
Browse