MCQs
The code shown above results in an error. This is because we have switched from automatic field numbering to manual field numbering, that is, from {} to {1}. Hence this code results in an error.
The output of both of the codes shown above is '0b1111111111111111'. Hence the statement is true.
In the code shown above, the function mk() is the decorator. The function which is getting decorated is mk2(). The return function is given the name p().
The code shown above first prints the word "Decorated and then "ordinary. Hence the output of this code is: Decorated
Ordinary
In the code shown above, we have used a decorator in order to avoid the Zero Division Error. Hence the output of this code is:
hello
NO
In order to add 'n' blank spaces after a given string 'S', we use the formatting option:("%-ns%S).
Within the subject string, curly braces designate substitution targets and arguments to be inserted either by position or keyword. Hence the output of the code shown above:'hello, good,and morning'.
The %f %e and %g format specifiers represent floating point numbers in different ways. %e and %E are the same, except that the exponent is in lowercase. %g chooses the format by number content. Hence the output of this code is: '3.345679 | 3.345679e+00 | 3.34568'.
The expression shown above rounds off the given number to the number of decimal places specified. Since the expression given specifies rounding off to two decimal places, the output of this expression will be 56.24. Had the value been x=56.234 (last digit being any number
less than 5), the output would have been 56.23.
In the code shown above, the decorator helps us to prefix the dollar sign along with the value. Since the second argument is zero, the output of the code is: $100.