COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
What is the output of the code shown below?L=list(’HELLO’)p=L[0], L[-1], L[1:3]’a={0}, b={1}, c={2}’.format(*p)
|
Error
|
|
a=’H’, b=’O’, c=[’E’, L’]
|
|
a=’H’, b=’E’, c=[’L’, L’, ‘O’]
|
|
a=’H’, b=’E’, c=’L’
|
Explanation:
Detailed explanation-1: -Explanation: The code shown above prints the values substituted for a, b, a, in the same order. This operation is performed using the format function. Hence the output of the code is: ‘helloworldhello’.
Detailed explanation-2: -Explanation: The code shown above returns a new list containing only those elements of the list l which do not amount to zero. Hence the output is: [1, 2, ‘hello’].
Detailed explanation-3: -What is the output of print 0.1 + 0.2 == 0.3? a) True b) False c) Machine dependent d) Error View Answer Answer: b Explanation: Neither of 0.1, 0.2 and 0.3 can be represented accurately in binary.
There is 1 question to complete.