Question 11
What is the output of the following code?
Solution
Given n = '0' and s = 'me',
- if
nandsisTrue; this is because while0is indicative of one of theFalse-like values,'0'is not an empty string given there are quotation marks surrounding it.0is not seen the same way as'0'here. Hence,n, s = s, nswaps the values ofnands, makingn = 'me'ands = '0'. Ignoreelif not nblock from here. if sisTrue, sinces = '0'is not an empty string. This leads tos *= 2which makess = '00'.- Print
s: prints'00'