In Python: #Q1: Consider the following variable. myvar = { 1:{\'name\': \'joe\',
ID: 3907339 • Letter: I
Question
In Python: #Q1: Consider the following variable. myvar = { 1:{'name': 'joe', 'age' : 20}, 2:{'name': 'john', 'age' : 30}} #Q1.1: What is the type of this variable. print('?' (myvar)) #1 point #Q1.2: We want to show joe as the result of the following code, # complete the following command such that it shows joe. print(myvar '?''?')#1 point #Q1.3: We want to add a new element to this variabe, #the person that we want to add is Mike, 25 years old. # complete the following commands. myvar[3] = '?' #(1 point) myvar[3]'?' = 'Mike' myvar[3]'?' = 25 print(myvar)
Explanation / Answer
myvar = {1: {'name': 'joe', 'age': 20}, 2: {'name': 'john', 'age': 30}} # Q1 print(type(myvar)) #1 point # Q2 print(myvar[1]['name'])#1 point # Q3 myvar[3] = {} #(1 point) myvar[3]['name'] = 'Mike' myvar[3]['age'] = 25 print(myvar)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.