0% found this document useful (0 votes)
6 views2 pages

Medical Records Analysis and Averages

The document contains medical data for several individuals, including their names, ages, BMI, and insurance costs. It processes this data by cleaning and organizing it, calculating the average BMI and insurance costs. Finally, it outputs a summary for each individual with their details formatted appropriately.

Uploaded by

ajnagoo554
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Medical Records Analysis and Averages

The document contains medical data for several individuals, including their names, ages, BMI, and insurance costs. It processes this data by cleaning and organizing it, calculating the average BMI and insurance costs. Finally, it outputs a summary for each individual with their details formatted appropriately.

Uploaded by

ajnagoo554
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

medical_data = \

"""Marina Allison ,27 , 31.1 ,


#7010.0 ;Markus Valdez , 30,
22.4, #4050.0 ;Connie Ballard ,43
, 25.3 , #12060.0 ;Darnell Weber
, 35 , 20.6 , #7500.0;
Sylvie Charles ,22, 22.1
,#3022.0 ; Vinay Padilla,24,
26.9 ,#4620.0 ;Meredith Santiago, 51 ,
29.3 ,#16330.0; Andre Mccarty,
19,22.7 , #2900.0 ;
Lorena Hodson ,65, 33.1 , #19370.0;
Isaac Vu ,34, 24.8, #7045.0"""

print(medical_data)

updated_medical_data = medical_data.replace('#', '$')


print(updated_medical_data)

num_records = sum(1 for char in updated_medical_data if char == '$')


print(f"There are {num_records} medical records in the data.")

medical_data_split = updated_medical_data.split(';')
print(medical_data_split)

medical_records = [[Link](',') for record in medical_data_split]


print(medical_records)

def clean_record(record):
return [[Link]() for item in record]

medical_records_clean = [clean_record(record) for record in medical_records]


print(medical_records_clean)

for record in medical_records_clean:


record[0] = record[0].upper()
print(record[0])

names = []
ages = []
bmis = []
insurance_costs = []

for record in medical_records_clean:


[Link](record[0])
[Link](record[1])
[Link](record[2])
insurance_costs.append(record[3])

print(names)
print(ages)
print(bmis)
print(insurance_costs)

total_bmi = 0
for bmi in bmis:
try:
total_bmi += float(bmi)
except ValueError:
print(f"Error converting {bmi} to float.")
average_bmi = total_bmi / len(bmis)
print(f"Average BMI: {average_bmi}")

total_cost = 0
for cost in insurance_costs:
try:
cost_clean = [Link]('$', '')
total_cost += float(cost_clean)
except ValueError:
print(f"Error converting {cost} to float.")
average_cost = total_cost / len(insurance_costs)
print(f"Average Insurance Cost: ${average_cost}")

for i in range(len(names)):
print(f"{names[i].title()} is {ages[i]} years old with a BMI of {bmis[i]} and
an insurance cost of {insurance_costs[i]}.")

You might also like