Chemical Elements Quiz

chemical-elementsThe aim of this challenge is to create a quiz based on the list of chemical elements of the periodic table based on the following requirements:

  • The quiz will include 10 questions.
  • Each question will display the name of an element (e.g. Aluminum) and ask the user to enter the symbol of this element (e.g. Al).
  • For each correct answer the user will score 2 points and for each incorrect answer, the user will lose 1 point.
  • The score cannot go in the negative values.
  • A feedback with the correct answer will be given after each question.
  • The final score (out of 20) will be displayed at the end of the quiz.

Python Dictionary


A Python dictionary is a mapping of unique keys to values. Each key is separated from its value by a colon (:), the items are separated by commas (,), and the whole set of key/value pairs is enclosed in curly braces {}.

For this challenge, we will use a dictionary data structure to store all the chemical elements of the periodic table using the symbol of each element as the key and the name of the element as the value. e.g.

Each value of a dictionary can be accessed by providing its key as follows (notice the use of square brackets [] to access a value from a dictionary):

Flowchart


To help you complete this challenge, we have created the flowchart of this quiz algorithm.
chemical-element-quiz-flowchart

Python Quiz


We have started the code for the Chemical Elements Quiz and created the Python dictionary containing all 118 chemical elements of the periodic table.

Your task is to complete the code to implement the full quiz based on the above mentioned requirements.

Share Button
Tagged with: