# Category Archives: Tutoring

CS101 CodeLab Solutions

# CodeLab Solution 51265

Given a dictionary d, create a new dictionary that reverses the keys and values of d. Thus, the keys of d become the values of the new dictionary and the values of d become the keys of the new dictionary. You may assume d contains no...
CS101 CodeLab Solutions

# CodeLab Solution 51265

Create a dictionary that maps the first n counting numbers to their squares. Associate the dictionary with the variable squares.

[cc lang="PYTHON"] squares=dict((n,n**2) for n in range(1,n+1)) [/cc]

...
CS101 CodeLab Solutions

# CodeLab Solution 51831

Given a variable , polygon_sides, that is associated with a dictionary that maps names of polygons to number of sides, create a new dictionary that maps number of sides to polygon names, and associate it with a variable n_polygons.

[cc...

CS101 CodeLab Solutions

# CodeLab Solution 51302

Given a dictionary d and a list lst, remove all elements from the dictionary whose key is an element of lst. For example, given the dictionary {1:2, 3:4, 5:6, 7:8} and the list [1, 7], the resulting dictionary would be {3:4, 5:6}. Assume every element of...