Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

python TaskS GMU-Mobile, a new cell phone initiative by GMU, is offering three n

ID: 3750363 • Letter: P

Question

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 Cost Per Month (S) S15 S20 S25 Free Calls (minutes) 100 175 250 Free Texts 1000 1500 2000 Price for additional Price for additional calls per minute 1.50 1.25 text (S) 0.75 Basic Standard Premium 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 (i.e., a student gets a maximurn 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, "Computer Science",False, 3.6) discount (20, "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", 5, 180) calculate cost("basic", 103, 70e) calculate cost("standard, 182, 699)28.0 calculate_cost("standard", 180, 1000) 26.25 calculate cost("premiun",18, 1680) 15.0 19.5 25.0 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, see) cost efficient plan (19, "Computer Science", False, 3.7, 185, 18) basic" cost efficient plan(19, "Computer Science" False, 3.5, 11e, 1ee0)standard" cost efficient plan(25, "Mechanical Engg True, 3., 178, 1see) standard" cost efficient plan(25, "Astronomy" False, 3.5, 260, 1se0) basic"

Explanation / Answer

Program contains 3 methods as described in problem.

1. discount(age: int, major: str, is_in_military: bool, gpa: float) = To check weather a person is eligible for discount or not

2. calculate_cost(plan: str, num_minutes: int, num_text: int) = To check the cost s/he has to pay based on the plan s/he will take and that persons usage statistics.

3. cost_efficient_plan(age: int, major: str, is_in_military: bool, gpa: float, num_minutes: int, num_text: int) = To check which plan will best suites that person.

Proper comments are given for each line of code and functions/methods used.

<-----------------------------------Program starts here ---------------------------------------------->

# Dict containing all the plan details.

# plans is an dictionary of 3 arrays.

# Each key is an plan name.

# Each array contains [cost per months, free calls, free texts, price for additional calls, price for additional texts.

plans = {

'basic': [15, 100, 1000, 1.50, .75],

'standard': [20, 175, 1500, 1.25, .5],

'premium': [25, 250, 2000, 1, .25],

}

# This discount method will check weeather a person is eligible for discount or not

# @params

# age:int = age of a person

# major:string = major of a person

# is_in_militart:boolean = weather a person is in military or not

# gpa:float = gpa of person

#

# @return

# boolean: Weather a person is eligible for discount or not

#

# First this method will check if a person belongs to "Computer Science" major and have gpa more than 3.5,

# then is eligible for discount.

# Second it will check if a person is age more than 65 or is_in_militart is true, then is eligible for discount.

# Otherwise returns False

def discount(age: int, major: str, is_in_military: bool, gpa: float):

if major == 'Computer Science' and gpa > 3.5:

return True

if is_in_military or age > 65:

return True

return False

# This function will calculate the cost person has to pay based on the plan and its usage.

#

# @param

# plan:str = Plan type should be ('basic','standard','premium')

# num_minutes:int = Number of minutes person will talk.

# num_texts:int = Number of texts person will send

#

# @return

# Float : return the float value of the cost person has to pay.

def calculate_cost(plan: str, num_minutes: int, num_text: int):

extra_calls_cost = 0

extra_texts_cost = 0

# Calculate extra costs person has to pay if s/he will use mesage more than giver in certain plan.

# The detail for each plan will be fetched by the plan dictionary.

# extra_texts will conatin the extra number of texts s/he has send.

# extra_texts_cost will conatins the cost of extra messages s/he has to pay.

if num_text > plans.get(plan)[2]:

extra_texts = num_text - plans.get(plan)[2]

extra_texts_cost = extra_texts * plans.get(plan)[4]

# Calculate extra costs person has to pay if s/he will use calls more than given in certain plan.

# The detail for each plan will be fetched by the plan dictionary.

# extra_calls will conatin the extra minutes of calls s/he has used.

# extra_calls_cost will conatins the cost of extra minutes s/he has to pay.

if num_minutes > plans.get(plan)[1]:

extra_calls = num_minutes - plans.get(plan)[1]

extra_calls_cost = extra_calls * plans.get(plan)[3]

# returns the sum of extra_calls_cost, extra_texts_cost and basic monthly cost for each plan

return float(extra_texts_cost + extra_calls_cost + plans.get(plan)[0])

# This function will calculate the cost for each plan based on giver person statistics and return the best plan

#

# @param

# age:int = age of a person

# major:string = major of a person

# is_in_militart:boolean = weather a person is in military or not

# gpa:float = gpa of person

# num_minutes:int = Number of minutes person will talk.

# num_texts:int = Number of texts person will send

#

# @return

# String = best plan type suited for the person. ('basic', 'standard', 'premium')

def cost_efficient_plan(age: int, major: str, is_in_military: bool, gpa: float, num_minutes: int, num_text: int):

# Check weather the person is elible for discount or not.

is_discount_applicable = discount(age, major, is_in_military, gpa)

# Caluclate the un-discounted price for basic plan based on person usage statistics(i.e., num_minutes and num_texts)

total_cost_basic = calculate_cost('basic', num_minutes, num_text)

# Caluclate the un-discounted price for standard plan based on person usage statistics(i.e., num_minutes and num_texts)

total_cost_standard = calculate_cost('standard', num_minutes, num_text)

# Caluclate the un-discounted price for premium plan based on person usage statistics(i.e., num_minutes and num_texts)

total_cost_premium = calculate_cost('premium', num_minutes, num_text)

# If a person is applicable for discount, it will give 20% discount on basic plan only.(based on given codition that

# basic plan if only eligible for dsicount)

if is_discount_applicable:

total_cost_basic = total_cost_basic * 0.2

# Compare if basic plan prices are less than standard plan and premium plan prices, return 'basic'

if (total_cost_basic < total_cost_premium) and (total_cost_basic < total_cost_standard):

return 'basic'

# Compare if standard plan prices are less than basic plan and premium plan prices, return 'standard'

if (total_cost_standard < total_cost_premium) and (total_cost_standard < total_cost_basic):

return 'standard'

# Compare if premium plan prices are less than standard plan and basic plan prices, return 'premium'

if (total_cost_premium < total_cost_standard) and (total_cost_premium < total_cost_basic):

return 'premium'

<------------------------- Program ends here ------------------------------------->