This is an archived version of the course and is no longer updated. Please find the latest version of the course on the main webpage.

Dictionary type - Exercises

Many thanks to the following people for contributing to these exercises: Joe Stacey, Oana Cocarascu

Ex1: Write a program that takes an integer from the user and creates a dictionary with all the numbers from 1 to that integer, where:
  • The key is the number
  • And the value is the square of that number.
Ex2: Concatenate together two different dictionaries into a single dictionary
Ex3: Use dict.fromkeys() to create a program that removes duplicate entries from a list, returning the list without the duplicate elements.
Ex4: Write a program to check whether a string is already a key within in a dictionary