A dictionary is declared as
V = {"p":25,"2":"A", 1:300,2: "B"}
Which of the following statements will be incorrect if written immediately after
the above declaration of V?
(a) V["P"]+=5 (b) V[1]+=10 (c) V["R"]=10 (d) V[3]+=5
Answers
Answered by
0
Answer:
(a) V["P"]+=5
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
V["P"]+=5
KeyError: 'P'
(b)
print(V[1]+=10)
SyntaxError: invalid syntax
(c)
print(V["R"]=10)
SyntaxError: keyword can't be an expression
(d)
print(V[3]+=5)
SyntaxError: invalid syntax
Explanation:
Similar questions