KnowledgeBoat Logo

Class - 12 CBSE Computer Science Important Output Questions 2025

Find and write the output of the following python code:

for Name in ['Jay', 'Riya', 'Tanu', 'Anil'] :
    print (Name)
    if Name[0] == 'T' :
        break
    else :
        print ('Finished!')
print ('Got it!')

Python Funda

9 Likes

Answer

Output
Jay
Finished!
Riya
Finished!
Tanu
Got it!
Explanation

The for loop iterates over each name in the list and prints it. If the name does not begin with the letter T, Finished! is printed after the name. If the name begins with T, break statement is executed that terminates the loop. Outside the loop, Got it! gets printed.

Answered By

4 Likes