Question

I need to write a Python Program for the following question. Link for tallest mountains: https://en.wikipedia.org/wiki/List_of_mountains_by_elevation Use top 10 tallest mountains. Part One Wikipedia...

I need to write a Python Program for the following question.

Link for tallest mountains: https://en.wikipedia.org/wiki/List_of_mountains_by_elevation

Use top 10 tallest mountains.

Part One

  • Wikipedia has a list of the tallest mountains in the world each mountain's elevation. Pick 10 mountains from this list.
    • Create a dictionary with the mountain names as keys, and the elevations as values.
    • Print out just the mountains' names, by looping through the keys of your dictionary.
    • Print out just the mountains' elevations, by looping through the values of your dictionary.
    • Print out a series of statements telling how tall each mountain is: "Everest is 8848 meters tall."

Part Two

  • Revise your final output from Mountain Heights, so that the information is listed in alphabetical order by each mountain's name.
    • That is, print out a series of statements telling how tall each mountain is: "Everest is 8848 meters tall."
    • Make sure your output is in alphabetical order.

Part Three

  • This is an extension of Mountain Heights. Make sure you save this program under a different filename, such as mountain_heights_3.py, so that you can go back to your original program if you need to.
    • The list of tallest mountains in the world provided all elevations in meters. Convert each of these elevations to feet, given that a meter is approximately 3.28 feet. Make sure you use a function to do this conversion
    • Create a new dictionary, where the keys of the dictionary are still the mountains' names. This time however, the values of the dictionary should be a list of each mountain's elevation in meters, and then in feet: {'everest': [8848, 29029]}
    • Print out just the mountains' names, by looping through the keys of your dictionary.
    • Print out just the mountains' elevations in meters, by looping through the values of your dictionary and pulling out the first number from each list.
    • Print out just the mountains' elevations in feet, by looping through the values of your dictionary and pulling out the second number from each list.
    • Print out a series of statements telling how tall each mountain is: "Everest is 8848 meters tall, or 29029 feet."
0 0
Add a comment Improve this question Transcribed image text
Answer #1
mountains={"Mount Everest":8848,"K2":8611,"Kangchenjunga":8586,
          "Lhotse":8516,"Makalu":8485,"Cho Oyu":8201,"Dhaulagiri":8167,
          "Manaslu":8163,"Nanga Parbat":8126,"Annapurna":8091}

print("\n====PART 1=====")
#part 1
print("Mountain names: ")
for i in mountains.keys():
    print(i)

print("Elevations: ")
for i in mountains.values():
    print(i)

for i in mountains:
    print(i,"is",mountains[i],"meters tall")

#part 2
print("\n====PART 2=====")
for i in sorted(mountains.keys()):
    print(i,"is",mountains[i],"meters tall")

#part 3

mountains={"Mount Everest":8848,"K2":8611,"Kangchenjunga":8586,
          "Lhotse":8516,"Makalu":8485,"Cho Oyu":8201,"Dhaulagiri":8167,
          "Manaslu":8163,"Nanga Parbat":8126,"Annapurna":8091}

def m2f(m):
    return m*3.28
a={i:[mountains[i],m2f(mountains[i])] for i in mountains}

print("\n====Part 3====")
print("\nMountain names:")
for i in a:
    print(i)
print("\nElevations in meters:")
for i in a:
    print(a[i][0])
print("\nElevations in feet:")
for i in a:
    print(a[i][1])
print()
for i in a:
    print(i,"is",a[i][0],"meters tall, or",a[i][1],"feet")

Elevations in feet: 29021.44 28244.079999999998 28162.079999999998 27932.48 27830.8 26899.28 26787.76 26774.64 26653.28 26538

Add a comment
Know the answer?
Add Answer to:
I need to write a Python Program for the following question. Link for tallest mountains: https://en.wikipedia.org/wiki/List_of_mountains_by_elevation Use top 10 tallest mountains. Part One Wikipedia...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT