>>> a={i: i*i for i in range(6)}
>>> aSelect an option to see the answer and solution.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
85
Questions
4/5
Page
Pick an option on a question to see the right answer and solution.
>>> a={i: i*i for i in range(6)}
>>> aSelect an option to see the answer and solution.
a = {}
a[1] = 1
a['1'] = 2
a[1.0]=4
count = 0
for i in a:
count += a[i]
print(count)Select an option to see the answer and solution.
Select an option to see the answer and solution.
d = {"john":40, "peter":45}
"john" in dSelect an option to see the answer and solution.
total={}
def insert(items):
if items in total:
total[items] += 1
else:
total[items] = 1
insert('Apple')
insert('Ball')
insert('Apple')
print (len(total))Select an option to see the answer and solution.
Select an option to see the answer and solution.
d = {"john":40, "peter":45}
d["john"]Select an option to see the answer and solution.
a={1:"A",2:"B",3:"C"}
print(a.get(5,4))Select an option to see the answer and solution.
a={1:"A",2:"B",3:"C"}
print(a.setdefault(3))Select an option to see the answer and solution.
Select an option to see the answer and solution.
a = {}
a[1] = 1
a['1'] = 2
a[1]=a[1]+1
count = 0
for i in a:
count += a[i]
print(count)Select an option to see the answer and solution.
>>> import collections
>>> a=dict()
>>> a=collections.defaultdict(int)
>>> a[1]Select an option to see the answer and solution.
Select an option to see the answer and solution.
a={}
a['a']=1
a['b']=[2,3,4]
print(a)Select an option to see the answer and solution.
>>> a={'B':5,'A':9,'C':7}
>>> sorted(a)Select an option to see the answer and solution.
>>> import collections
>>> b=dict()
>>> b=collections.defaultdict(lambda: 7)
>>> b[4]Select an option to see the answer and solution.
>>> a={"a":1,"b":2,"c":3}
>>> b=dict(zip(a.values(),a.keys()))
>>> bSelect an option to see the answer and solution.
Select an option to see the answer and solution.
>>> a={i: 'A' + str(i) for i in range(5)}
>>> aSelect an option to see the answer and solution.
>>> b={}
>>> all(b)Select an option to see the answer and solution.