MCQs
The list comprehension shown above rounds off pi(3.141) and returns its value, that is 3. This is done 5 times. Hence the output is: ['3', '3', '3', '3', '3'].
Execute in the shell and verify.
The value of t in the code shown above is equal to 32.00, which is a floating point value. 'Float' objects are not iterable. Hence the code results in an error.
We are iterating over each letter in the string.
split() function returns the elements in a list.
The above copy is deepcopy. Any change made in the original list isn't reflected.
List Comprehension are a shorthand for creating new lists.
Execute in the shell to verify.
(45) is an int while (45,) is a tuple of one element. Thus when a tuple is multiplied, it created references of itself which is later converted to a list.