# Hey guys, here is my U.S. Medical insurance costs portfolio project, would be really healpfult o get your review

import csv

with open (‘insurance.csv’) as insurance_file:
age =
sex =
bmi =
children =
smoker =
region =
charges =

``````reader = csv.DictReader(insurance_file)
age.append(int(row['age']))
sex.append(row['sex'])
bmi.append(float(row['bmi']))
children.append(int(row['children']))
smoker.append(row['smoker'])
region.append(row['region'])
charges.append(float(row['charges']))
``````

#Find out the average age of the patients in the dataset.

class average:

``````def __init__ (self,age):
self.age = age

def averageAge (self, age):
self.age = age
sum = 0
for i in self.age:
sum = sum + self.age[i]
average = float(sum / len(self.age))
return average
``````

averageAge = average(age)
print(averageAge.averageAge(age))

#Analyze where a majority of the individuals are from.

class CalculateRegion:
def init (self, region):
self.region = region

``````def calculate(self, region):
self.region = region
southwest = 0
southeast = 0
northwest = 0
northeast = 0
for i in region:
if i == 'southwest':
southwest = southwest +1
elif i == 'southeast':
southeast = southeast + 1
elif i == 'northwest':
northwest = northwest + 1
elif i == 'northeast':
northeast = northeast + 1

calculatedRegions = "Southwest: " + str(southwest) + " " + "Southeast: " + str(southeast) + "northwest: " + str(northwest) + " northeast: " + str(northeast)
return calculatedRegions
``````

numRegions = CalculateRegion(region)

print(numRegions.calculate(region))

#Figure out what the average age is for someone who has at least one child in this dataset.
a_and_c = list(zip(charges, children))
#print(a_and_c)
def calculateAverageAge(lst):
num_atleast_1 = 0
sum =0
for (x,y) in lst:
if y > 0:
num_atleast_1 +=1
sum = sum + float(x)
average = sum/num_atleast_1
return average, num_atleast_1

print(calculateAverageAge(a_and_c))

#Look at the different costs between smokers vs. non-smokers.

s_c = list(zip(sex, charges))
#print(sns_c)

def difference(lst):

``````male_charges =0
female_charges = 0

for (x,y) in lst:
if x == 'male':
male_charges = male_charges + y

elif x == 'female':
female_charges = female_charges + y

display = "total charge for males is {}. total charge for females is {}". format(male_charges, female_charges)

return display
``````

print(difference(s_c))

Congrats on completing the project!

It would be a bit easier to read and see the output of your code if you just post a link to your Jupyter notebook (or Google Colab notebook) from your GitHub repo for this project.