Question: Please help, I'm not very good at Python! Exercise #1 name: calc_paycheck arguments: *hours( int ), *wage( float ), *ot( bool ;optional: default =False), returns:

Please help, I'm not very good at Python!

Exercise #1

name:

calc_paycheck 

arguments:

*hours(int),  *wage(float),  *ot(bool;optional:default=False), 

returns:

calcuatethetotalweeklypayforaworkerwiththeformula`hours`*`wage`.Iftheworkerisovertimeeligible(denotedbyparameter`ot`)theywillreveive150%oftheirhourlywageforanytimeover40hours. 

### calc_paycheck goes here

assert calc_paycheck(40, 10.) == 400

assert calc_paycheck(41, 10.) == 410

assert calc_paycheck(41, 10., ot=True) == 415

assert calc_paycheck(0, 10.) == 0

assert calc_paycheck(80, 20., ot=True) == 2000

Exercise 2:

name:

better_deal 

arguments:

*lump_sum(numeric),  *hours(int),  *wage(float),  *ot(bool;optional:default=False), 

returns:

UsethefunctionyouwroteinExercise#1(`calc_paycheck`)tochosebetweena"lumpsum"paymentor"hourlywage"foragiventask.Ifthetotalpayforalumpsumis>=thetotalpayfromanhourlywagereturnthestring"lumpsum"otherwisereturnthestring"hourlywage". 

Note:

YouMUSTcallthefunction`calc_paycheck`fromexercise1inyourfunction. 

### better_deal goes here

assert better_deal(2000, 40, 10) == 'lump sum'

assert better_deal(200, 40, 10) == 'hourly wage'

assert better_deal(412, 41, 10) == 'lump sum'

assert better_deal(412, 41, 10, True) == 'hourly wage'

Exercise 3:

name:

calc_distance 

arguments:

*point_a(tupleoflength2,ie(4,2)ascoordinantsina2dcoordinateplane)  *point_b(sameaspoint_a) 

returns:

Thedistancebetweenthe2pointsina2dcoordinateplane 

### calc_distance goes here

assert calc_distance((0, 0), (0, 1)) == 1

assert calc_distance((0, 0), (0, 0)) == 0

assert calc_distance((0, 0), (0, -1)) == 1

assert calc_distance((3, 2), (9, 7)) == 61**.5

Exercise 4:

name:

closest_city 

arguments:

*taget_city(string,mustbeakeyin`city_coordinates`whichisdefinedbelow) 

returns:

Thenameofthenearestcityinstraightlinedistancetothetargetcity.Usethefunction`calc_distance`thatyoudefinedinecercise#3.Considerthedictionary`city_coordinates`givenbelowaglobalvariableanduseit'svaluesasthelocationofeachcitydefinedbyit'srespectivekey.Youmustrunthecellbelowtoregisterthedictionary`city_coordinates`.Seetheassertstatementsforuseageexamples. 

Note:

YouMUSTcallthefunction`calc_distance`fromexercise3inyourfunction. 

city_coordinates = {

'Hong Kong': (9, 10),

'New York': (2, 2),

'Los Angeles': (-10, 12),

'Tokyo': (0, 2),

'London': (-3, -3),

'Toronto': (5, 5),

'Rome': (-14, 0),

'Paris': (10, 10),

}

### closest_city goes here

assert closest_city('Tokyo') == 'New York'

assert closest_city('Toronto') == 'New York'

assert closest_city('Hong Kong') == 'Paris'

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!