Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created October 30, 2020 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/9c2c21b22f1c9561bb783c314ad857ab to your computer and use it in GitHub Desktop.
Save codecademydev/9c2c21b22f1c9561bb783c314ad857ab to your computer and use it in GitHub Desktop.
Codecademy export
import operator
names = ["Mohamed", "Sara", "Xia", "Paul", "Valentina", "Jide", "Aaron", "Emily", "Nikita", "Paul"]
insurance_costs = [13262.0, 4816.0, 6839.0, 5054.0, 14724.0, 5360.0, 7640.0, 6072.0, 2750.0, 12064.0]
# Add your code here
names.append("Priscilla")
insurance_costs.append(8320.0)
medical_records = zip(names,insurance_costs)
medical_records = list(medical_records)
print(medical_records)
num_medical_records = len(medical_records)
print("There are " + str(num_medical_records) + " medical records.")
first_medical_record = medical_records[0]
print('Here is the first medical record: ' + str(first_medical_record))
medical_records = sorted(medical_records, key = operator.itemgetter(1))
print("Here are the medical records sorted by insurance cost: "+ str(medical_records))
cheapest_three = medical_records[:3]
print("Here are the three cheapest insurance costs in our medical records: " + str(cheapest_three))
priciest_three = medical_records[-3:]
print("Here are the three most expensive insurance costs in our medical records: " + str(priciest_three))
occurences_paul = names.count('Paul')
print("There are " + str(occurences_paul) + " individuals with the name Paul in our medical records")
middle_five_records = medical_records[3:8]
print(middle_five_records)
@lemonstu
Copy link

lemonstu commented Mar 3, 2021

Thank you so much - I've wasted 2 hours trying to figure it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment