Computer Science

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")

Python Control Flow

12 Likes

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")

Answered By

10 Likes


Related Questions