Computer Science
Fill in the blanks of the following code so that the values and keys of dictionary d are inverted to create dictionary fd.
d = {'a':1, 'b':2, 'c':3}
print(d)
fd = {}
for key, value in d.____():
fd[____] = ____
print(fd)
Related Questions
Find the error/output. Consider below given two sets of codes. Which one will produce an error? Also, predict the output produced by the correct code.
(a)
box = {} jars = {'Jam' :4} crates = {} box['biscuit'] = 1 box['cake'] = 3 crates['box'] = box crates['jars'] = jars print(len(crates[box]))(b)
box = {} jars = {'Jam' :4} crates = {} box['biscuit'] = 1 box['cake'] = 3 crates['box'] = box crates['jars'] = jars print(len(crates['box']))Predict the output :
dct = {} dct[1] = 1 dct ['1'] = 2 dct[1.0] = 4 sum = 0 for k in dct: print(k, sum) sum += dct[k] print(sum)Write a program to enter names of employees and their salaries as input and store them in a dictionary.
Write a program to count the number of times a character appears in a given string.