QUESTION IMAGE
Question
- suppose d = {\peter\:46, \john\:56}, what happens when retrieving a value using d\juan\?
since \juan\ is not a key in the set, python raises a syntax error.
since \juan\ is not a key in the set, python raises a keyerror exception.
since \juan\ is not a value in the set, python raises a keyerror exception.
it is executed fine, no exception is raised, and it returns none.
- which of the following is a python tuple?
(1, 2, 3)
{}
{1, 2, 3}
1, 2, 3
- suppose d1 = {\kevin\:31, \anthony\:34} and d2 = {\kevin\:376, \anthony\:34}, d1 > d2 will return
true
an error message
false
Brief Explanations
- In Python, when trying to access a non - existent key in a dictionary, a KeyError exception is raised. "juan" is not a key in the given dictionary
d. - In Python, tuples are enclosed in parentheses.
(1, 2, 3)is a tuple,{}is an empty dictionary,{1, 2, 3}is a set, and[1, 2, 3]is a list. - Dictionaries in Python do not support direct comparison using the
>operator. This will raise an error message.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
- Since "juan" is not a key in the set, Python raises a KeyError exception.
- (1, 2, 3)
- An error message