Mountains Elevation Quiz

For this quiz we will use a data set of 10 of the most iconic mountains in the world. (Not that these are not necessary to top 10 highest mountains in the world).

Here is our data set, displayed as a table:

Name Location Elevation
Mount Everest Nepal / Tibet 8,849m
Mount K2 Pakistan / China 8,611m
Mount Aconcagua Argentina 6,959m
Mount McKinley Alaska, USA 6,190m
Mount Kilimanjaro Tanzania 5,895m
Mount Kenya Kenya 5,199m
Mount Blanc France 4,809m
Mount Fuji Japan 3,776m
Mount Etna Italy 3,369m
Ben Nevis Scotland, UK 1,345m

This data set will be stored in a Python program using a 2D array (list of lists) as follows:

mountains = [["Mount Everest","Nepal / Tibet",8849],
             ["Mount K2","Pakistan / China",8611],
             ["Mount Aconcagua","Argentina",6959],
             ["Mount McKinley","Alaska, USA",6190],
             ["Mount Kilimanjaro","Tanzania",5895],
             ["Mount Kenya","Kenya",5199],
             ["Mount Blanc","France",4809],
             ["Mount Fuji","Japan",3776],
             ["Mount Etna","Italy",3369],
             ["Ben Nevis","Scotland, UK",1345]]

Using the random library we can easily pick a random peak from this 2D array and display its name, location and elevation:

import random

number = random.randint(0,len(mountains)-1)
peak = mountains[number]
name = peak[0]
location = peak[1]
elevation = peak[2]
print(">>> Did you know?")
print(name + " is located in " + location + " and rises to " + str(elevation) + " meters." )

Your challenge

Your task is to create a quiz based on this data set. The rules of the quiz are as follows:

     A player starts with a health of 10,000 points and a score of 0.
     The computer randomly selects a peak from the data set and displays the name of the peak and its location.
     It then asks the player to estimate the elevation of the selected peak.
     The computer calculates the difference in meters between the answer given by the player and the real elevation of the peak and deducts this difference from the player’s health score.
     If the player’s health score is positive, then the player’s score goes up by 1 point.
     The quiz repeats itself for as long as the player’s health score remains positive.
     Once the player’s health score reaches zero or a negative value, a game over message is displayed alongside the player’s total score.

Python Code

You can complete your quiz by editing the Python code below:

unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 4.1 / 5. Vote count: 14

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!