Computer Science
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!')
Python
Python Funda
45 Likes
Answer
Jayes
Finished!
Ramya
Finished!
Taruna
Got it!
Working
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
11 Likes
Related Questions
Write a program that reads a date as an integer in the format MMDDYYYY. The program will call a function that prints print out the date in the format <Month Name> <day>, <year>.
Sample run :
Enter date : 12252019 December 25, 2019
Write a program that prints a table on two columns — table that helps converting miles into kilometres.
Write another program printing a table with two columns that helps convert pounds in kilograms.
Write a program that reads two times in military format (0900, 1730) and prints the number of hours and minutes between the two times.
A sample run is being given below :
Please enter the first time : 0900 Please enter the second time : 1730 8 hours 30 minutes