![]() |
VOOZH | about |
Prerequisite -
Loops in PythonPredict the output of the following Python programs.
['ab', 'cd']Explanation: The function upper() does not modify a string in place, but it returns a new string which here isn’t being stored anywhere. So we will get our original list as output.
No OutputExplanation: The loop does not terminate as new elements are being added to the list in each iteration. So our program will stuck in infinite loop
No OutputExplanation: The program will give no output as there is an error in the code. In python while using expression there shouldn’t be a space between + and = in +=.
Error!Explanation: Objects of type int are not iterable instead a list, dictionary or a tuple should be used.
4Explanation: Adding [::-1] beside your list reverses the list. So output will be the elements of original list but in reverse order.
3
2
1