MCQs
The function round is used to round off the given decimal number to the specified decimal places. In this case the number should be rounded off to two decimal places. Hence the output will be 4.57.
See python documentation for the function divmod.
The get() method returns the value of the key if the key is present in the dictionary and the default value(second parameter) if the key isn't present in the dictionary.
The function hex() is used to convert the given argument into its hexadecimal representation, in lower case. Hence the output of the function hex(15) is 0xf.
Execute in the shell to verify.
The insert() function counts the number of occurrences of the item being inserted into the dictionary. There are only 2 keys present since the key 'Apple' is repeated. Thus, the length of the dictionary is 2.
The global statement is used to declare that x is a global variable “ hence, when we assign a value to x inside the function, that change is reflected when we use the value of x in the main block.
Now, a={1:[2,3,4],2:1} . a[1][1] refers to second element having key 1.