Explanations "Top Python Quiz Questions"
349 subscribers
80 photos
1 link
Explanations "Top Python Quiz Questions"
Download Telegram
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.
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.
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.
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].
What is the output of the program?

Specific ZeroDivisionError Specific ZeroDivisionError
Specific ZeroDivisionError Finally ZeroDivisionError
Specific IndexError General IndexError Finally ZeroDivisionError
Finally IndexError Specific ZeroDivisionError Finally ZeroDivisionError
Finally IndexError Specific ZeroDivisionError General ZeroDivisionError Finally ZeroDivisionError
Finally IndexError Specific ZeroDivisionError
None of the above

Explanation:
"finally" block of code is always executed whether the exception occurs or not. If exception occurs, the except block is executed first matched by exception type.

General try and except concept:
First try clause is executed i.e. the code between try and except clause.
If there is no exception, then only try clause will run, except clause will not get executed.
If any exception occurs, the try clause will be skipped and except clause will run.
If any exception occurs, but the except clause within the code doesn’t handle it, it is passed on to the outer try statements. If the exception is left unhandled, then the execution stops.
A try statement can have more than one except clause.
What is the output of the code?

['top', 'quiz']
['TOP', 'QUIZ']
['top', 'quiz', 'TOP', 'QUIZ']
[None, None]
[]
None of the above

Explanation:
The loop does not terminate and will run without end because new elements are being added to the list in each iteration.