<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Assignment 2
Create two models for the relationship between height and weight based on gender
Modify the code in Assignment 1 to ask for a person's gender as well as their height to produce an estimate of a person's weight using the models you created
Find the weights and use those in your function (i.e. don't generate a model each time)
Step1:  For Female
Step2:  For Male
Step3:  Function
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')
%matplotlib inline
import statsmodels.formula.api as smf
df = pd.read_csv('heights_weights_genders.csv')
df.head(3)
female_df = df[df['Gender'] == 'Female']
male_df = df[df['Gender'] == 'Male']
Explanation: Assignment 2
Create two models for the relationship between height and weight based on gender
Modify the code in Assignment 1 to ask for a person's gender as well as their height to produce an estimate of a person's weight using the models you created
Find the weights and use those in your function (i.e. don't generate a model each time)
End of explanation
female_df.describe()
lm = smf.ols(formula="Weight~Height",data=female_df).fit()
lm.params
female_intercept, female_slope = lm.params
female_df.plot(kind="scatter",x="Height",y="Weight")
plt.plot(female_df["Height"],female_slope*female_df["Height"]+female_intercept,"-",color="darkgrey") 
plt.title('Correlation between height and weight for females')
plt.xlabel('Height (inches)')
plt.ylabel('Weight (lbs)')
Explanation: For Female:
End of explanation
male_df.describe()
lm = smf.ols(formula="Weight~Height",data=male_df).fit()
lm.params
male_intercept, male_slope = lm.params
male_df.plot(kind="scatter",x="Height",y="Weight")
plt.plot(male_df["Height"],male_slope*male_df["Height"]+male_intercept,"-",color="darkgrey") 
plt.title('Correlation between height and weight for males')
plt.xlabel('Height (inches)')
plt.ylabel('Weight (lbs)')
Explanation: For Male:
End of explanation
gender = input('Male or female? ')
if gender == 'female' or gender == 'Female':
    height = int(input('Height (in inches): '))
    weight = female_slope * height + female_intercept
    print('If a person is female and ' + str(height) + ' inches tall, they probably weigh ' + str(round(weight,2)) + ' pounds.')
elif gender == 'male' or gender == 'Male':
    height = int(input('Height (in inches): '))
    weight = male_slope * height + male_intercept 
    print('If a person is male and ' + str(height) + ' inches tall, they probably weigh ' + str(round(weight,2)) + ' pounds.')
        
else:
    print("Input error.")
gender = input('Male or female? ')
if gender == 'female' or gender == 'Female':
    height = int(input('Height (in inches): '))
    weight = 5.994047 * height - 246.013266
    print('If a person is female and ' + str(height) + ' inches tall, they probably weigh ' + str(round(weight,2)) + ' pounds.')
elif gender == 'male' or gender == 'Male':
    height = int(input('Height (in inches): '))
    weight = 5.961774 * height - 224.498841
    print('If a person is male and ' + str(height) + ' inches tall, they probably weigh ' + str(round(weight,2)) + ' pounds.')
        
else:
    print("Input error.")
Explanation: Function:
End of explanation
<END_TASK>