CBSE Class 11 Computer Science Question 122 of 161

Flow of Control — Question 31

Back to all questions
31
Question

Question 14

Which of the following Python programs implement the control flow graph shown?

Which of the following Python programs implement the control flow graph shown

(a)

while True :
   n = int(input("Enter an int:"))
   if n == A1 :
      continue
   elif n == A2 :
      break
   else :
      print ("what")
else:
   print ("ever")

(b)

while True :
   n = int(input("Enter an int:"))
   if n == A1 :
      continue
   elif n == A2 :
      break
   else :
      print ("what")
print ("ever")

(c)

while True :
   n = int(input("Enter an int:"))
   if n == A1 :
      continue
   elif n == A2 :
      break
print ("what")
print ("ever")

Answer

Python program given in Option (b) implements this flowchart:

while True :
   n = int(input("Enter an int:"))
   if n == A1 :
      continue
   elif n == A2 :
      break
   else :
      print ("what")
print ("ever")
Answer