Question
just part 3 please python
Tasks GMU-Mobile, a new cell phone initiative by GMU, is offering three new cell phone plans to its students starting 2019. Your task is to help your friends decide which cell phone plan to purchase based on their monthly usage Refer to the table below to see a description of the monthly plans. Plan Basic Standard Premium Cost Per Month (S) $15 $20 Free Calls Free minutes 100 175 250 Texts 1000 1500 2000 Price for addition Price for additional calls per minute (S) text( 1,50 1.25 0.75 0.25 discount(age, major, is in_military, gpa): First, we will check to see if a student gets a discount, given the student details. All the discounts are 20% of the overall monthly cost and are only for the basic plan. The Computer Science department is offering its students (exclusively for CS majors) the discount if their GPA is or above 3.5. Students in the military and senior citizens (age 65+), regardless of their major receive the discount. Discounts cannot be stacked (ie, a student gets a maximum of 20% discount) Assume age is a non-negative int, major is a string, is in military is a bool, and gpa is a float. The answer is returned as a bool. Note that the string cs is not the same as "Computer Science" discount (34, "Biology", True, 3.5) discount (35, "Biology", False, 3.5) discount (66, "Physics", False, 3.8) discount (21, "Conputer Science", False, 3.6) discount (28, "cs", False, 3.7) True False True True False calculate cost(plan, num_minutes, num text): Given the plan type, number of minutes, and number of text messages, calculate the cost. The answer is returned as a float. Assume plan is a string, and num minutes and num_text are non-negative ints. Assume that the parameter plan is always given a valid choice: "basic" "standard", or "premium calculate cost("basic", 58, 188) calculate cost("basic", 183, 780) calculate cost( standard", 182, 699 20.8 calculate cost("standard, 180, 126.25 calculate cost("premium,180, 160) 25.0 15.8 19.5 cost efficient plan(age, major, is in_military, gpa, num minutes, num text): Given the age, major, whether the student is in military, gpa, number of minutes, and number of text messages, determines which plan is the best. The answer is returned as a string. You will find the other two functions discount and calculate cost helpful in implementing this function. Tie-breaking: if the cost of any two plans are the same, choose the plan with more free minutes. Assume num_minutes, num_text, and age are non-negative ints, major is a string, is_in_military is a bool, and gpa is a float cost efficient_plan (18, "Biology False, 3.7, 5e, 508) cost efficient_plan (19, "Computer Science, False, 3.7, 15, 10) "basic" -"basic" cost efficient_plan (19, "Computer Science", False, 3.5, 118, 1)"standard" cost efficient_plan (25, "Mechanical Engg", True, 3., 178, 15e0) "standard" cost efficient_plan(25, "Astronomy" False, 3.5, 268, 15e0) "premium
Explanation / Answer
def cost_efficient_plan(age, major, is_in_military, gpa, num_minutes, num_text):
dis = discount(age, major, is_in_military, gpa)
disc = 0
if dis:
disc = 20
basi = calculate_cost("basic", num_minutes, num_text)
basi = basi*(1-(disc/100.0))
stan = calculate_cost("standard", num_minutes, num_text)
prem = calculate_cost("premium", num_minutes, num_text)
if basi<stan and basi<prem:
return "basic"
elif stan<=basi and stan<prem:
return "standard"
else return "premium"