What will be the value of 'result' variable?
✅ [1, 3, 5, 7, 8]
❌ [1, 7, 8]
❌ [1, 2, 4, 7, 8]
❌ Error
❌ None of the above
Explanation:
Here, 'result' is a list which is extending three times. When first time 'extend' function is called for 'result', the inner code generates a generator object, which is further used in 'extend' function. This generator object contains the values which are in 'list1' only (not in 'list2' and 'list3').
Same is happening in second and third call of 'extend' function in these generator object contains values only in 'list2' and 'list3' respectively. So, 'result' variable will contain elements which are only in one list (not more than 1 list).
✅ [1, 3, 5, 7, 8]
❌ [1, 7, 8]
❌ [1, 2, 4, 7, 8]
❌ Error
❌ None of the above
Explanation:
Here, 'result' is a list which is extending three times. When first time 'extend' function is called for 'result', the inner code generates a generator object, which is further used in 'extend' function. This generator object contains the values which are in 'list1' only (not in 'list2' and 'list3').
Same is happening in second and third call of 'extend' function in these generator object contains values only in 'list2' and 'list3' respectively. So, 'result' variable will contain elements which are only in one list (not more than 1 list).
What is the value of L at the end of execution of the program?
❌ [6.222e-04, ‘aboy’, True, 641]
❌ [6.2202, ‘aboy’, 1, 641]
❌ [6.2202, ‘aboy’, False, 87]
✅ TypeError
❌ None of the above
Explanation:
The for loop will run for i = 0 to i = 3, i.e. 4 times(len(L) = 4). 2e-04 is same as 0.0002, thus L[i] = 6.22 + 0.0002 = 6.2202. String addition will result in concatenation, ‘a’ + ‘boy’ = ‘aboy’. False + True is True, it’ll return the integer value of 1. As tuples are immutable, the code will end with TypeError, but elements of L will be updated.
❌ [6.222e-04, ‘aboy’, True, 641]
❌ [6.2202, ‘aboy’, 1, 641]
❌ [6.2202, ‘aboy’, False, 87]
✅ TypeError
❌ None of the above
Explanation:
The for loop will run for i = 0 to i = 3, i.e. 4 times(len(L) = 4). 2e-04 is same as 0.0002, thus L[i] = 6.22 + 0.0002 = 6.2202. String addition will result in concatenation, ‘a’ + ‘boy’ = ‘aboy’. False + True is True, it’ll return the integer value of 1. As tuples are immutable, the code will end with TypeError, but elements of L will be updated.
What is the output of the code?
❌ 12
✅ 11
❌ 11.001199999999999
❌ TypeError
❌ None of the above
Explanation:
Integer value of 2e-04(0.0002) is 0, True holds a value 1 and False a 0, integer value of 1.001 is 1. Thus total 0 + 1 + 0 + 8 + 1 + 1 = 11.
❌ 12
✅ 11
❌ 11.001199999999999
❌ TypeError
❌ None of the above
Explanation:
Integer value of 2e-04(0.0002) is 0, True holds a value 1 and False a 0, integer value of 1.001 is 1. Thus total 0 + 1 + 0 + 8 + 1 + 1 = 11.
What is the output of the code?
❌ False
✅ True
❌ None
❌ Error
❌ None of the mentioned
Explanation:
Each elements of the tuples are compared one by one and if maximum number of elements are there in tuple1 which are greater or equal to corresponding element of tuple2 then tuple1 is said to be greater than tuple2.
❌ False
✅ True
❌ None
❌ Error
❌ None of the mentioned
Explanation:
Each elements of the tuples are compared one by one and if maximum number of elements are there in tuple1 which are greater or equal to corresponding element of tuple2 then tuple1 is said to be greater than tuple2.
What is the output of the code?
✅ (0, 'P')(1, 'Y')(2, 'T')(3, 'H')(4, 'O')(5, 'N')
❌ ('PYTHON')
❌ ('P','Y','T','H','O','N')
❌ Error
❌ None of the mentioned
Explanation:
Enumerate is a built-in function that iterates through a sequence and gets the index and values simultaneously. Enumerate ( ) returns a pair value of index values and its list element.
✅ (0, 'P')(1, 'Y')(2, 'T')(3, 'H')(4, 'O')(5, 'N')
❌ ('PYTHON')
❌ ('P','Y','T','H','O','N')
❌ Error
❌ None of the mentioned
Explanation:
Enumerate is a built-in function that iterates through a sequence and gets the index and values simultaneously. Enumerate ( ) returns a pair value of index values and its list element.
What is the output of the code?
❌ True False
✅ False True
❌ False False
❌ True True
❌ Error
Explanation:
The objects with same contents share the same object in the python library but this is not true for custom-defined immutable classes.
❌ True False
✅ False True
❌ False False
❌ True True
❌ Error
Explanation:
The objects with same contents share the same object in the python library but this is not true for custom-defined immutable classes.
What will be displayed by the code?
❌ 1 1
❌ 1 44
❌ 3 1
✅ 3 44
❌ Error
❌ None of the above
Explanation:
The value of t=3 is passed in funcion f(value,values) , v [list] is passed as values in the same function. The v is stored in values and values[0]=44 , changes the value at index[‘0’] in the list hence v=[44,2,3].
❌ 1 1
❌ 1 44
❌ 3 1
✅ 3 44
❌ Error
❌ None of the above
Explanation:
The value of t=3 is passed in funcion f(value,values) , v [list] is passed as values in the same function. The v is stored in values and values[0]=44 , changes the value at index[‘0’] in the list hence v=[44,2,3].