Courses‎ > ‎Intro to CS - Full Year‎ > ‎Spring‎ > ‎Dyrland-Weaver‎ > ‎Work‎ > ‎

### Work 20: 3/26

posted Mar 26, 2019, 11:20 AM by JonAlf Dyrland-Weaver   [ updated Mar 26, 2019, 12:14 PM ]
 Write the following python functions, use elif in each, trying to minimize the length of each conditional test used:sale_priceTakes 2 arguments, the first represents the original price of an item, the second represents the number of weeks it has been on sale.Returns the current price of the item based on how many weeks it has been on sale.Items on sale for 0 weeks will cost the full amountItems on sale for 1 week will cost 75% of the full amountItems on sale for 2 weeks will cost 50% of the full amountItems on sale for 3 or more weeks will cost 25% of the full amount.Examplessale_price(200, 0) ==> 200sale_price(200, 1) ==> 150sale_price(200, 2) ==> 100sale_price(200, 3) ==> 50productionTakes 2 arguments, the first represents an hour of the day between 6 and 20 (8pm in 24 hour time format), the second represents the number of workers at a factory.Returns the number of widgets produced by the factory in the given hour by the given number of employees.The amount of widgets a worker makes is based on the time of dayBetween 6 and 10 (including 6 but excluding 10) each worker can make 30 widgets in an hour.Between 10 and 14 (including 10 but excluding 14) each worker can make 40 widgets in an hour.Between 14 and 20 (including 14 but excluding 20) each worker can make 35 widgets in an hour.You can assume that only valid times are provided for the hour parameter.Examplesproduction(8, 2) ==> 60production(13, 4) ==> 160production(17, 1) ==> 35letter_gradeReturns a letter grade based on a numeric grade out of 100 using the following scale:grade >= 90 ==> e90 > grade >= 75 ==> s75 > grade >= 65 ==> n65 > grade ==> uis_leap_yearTakes a single parameter representing a year.Returns True if the year is a leap year, and False if it is notThe rules for leap year-ness are as followsYears that are divisible by 4 are leap years, except:Years that are divisible by 100 are not leap years except:Years that are divisible by 400 are leap years.Examplesis_leap_year(2012) ==> Trueis_leap_year(1900) ==> Falseis_leap_year(2000) ==> Trueis_leap_year(1983) ==> Falsesubmit this as elif