Q. Find and write the output of the following python code:
for Name in ['Jayes', 'Ramya', 'Taruna', 'Suraj'] :
print (Name)
if Name[0] == 'T' :
break
else :
print("Finished!")
print ('Got it!')
Answer =
Jayes
Finished!
Ramya
Finished!
Taruna
Got it!
>>>
Explanation :
Iterates through the list of names: 'Jayes', 'Ramya', 'Taruna', 'Suraj'.
For each name, it prints the name.
Checks if the first letter of the current name is 'T'. If it is, the loop breaks.
If the first letter is not 'T', it prints "Finished!" after printing the name.
After the loop is finished or broken, it prints 'Got it!'
suraj not taruna
ReplyDeleteYou are wrong it will taruna. If you have doubt then please run it in your pc.
DeleteTaruna
ReplyDeleteGot it
Suraj
Finished!
Is it correct
No, You are wrong. Please copy the code and paste it in your python.
DeleteCan you explain me this code
ReplyDeleteok.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )