5.28. Functions and Conditionals Write Code Questions¶
Write a function called
cropped_photo
that takes theheight
andwidth
of a photo. If theheight
andwidth
are equal, then the function returns"Cropped Photo"
. Otherwise, it returns"The photo needs to be cropped."
Assumeheight
andwidth
are positive. For example,cropped_photo(23.2, 23.2)
should return"Cropped Photo"
.Write a function called
cropped_photo
that takes theheight
andwidth
of a photo. If theheight
andwidth
are equal, then the function returns"Cropped Photo"
. Otherwise, it returns"The photo needs to be cropped."
Assumeheight
andwidth
are positive. For example,cropped_photo(23.2, 23.2)
should return"Cropped Photo"
.-
Write a function called
bonus
that takes two parameters,years
andquality
. Ifyears
is more than 5, then the person gets a bonus. The person also gets a bonus if theirquality
of work was more than 90. They can also get a bonus if they worked for at least 3years
and hadquality
more than 80. If the person is eligible for a bonus, return"Eligible for Bonus"
. Otherwise, return"Ineligible for Bonus"
. For example,bonus(3, 81)
should return"Eligible for Bonus"
. Write a function called
move_elevator
that takes two parameters,current_floor
andnext_floor
. If the elevator moves to a floor above, then it should return"Up"
. Otherwise, it should return"Down"
. Also, ifnext_floor
is the same ascurrent_floor
, it should return 0. Assume there are no 0 or negative floors. For example,move_elevator(5, 8)
should return"Up"
.Write a function called
move_elevator
that takes two parameters,current_floor
andnext_floor
. If the elevator moves to a floor above, then it should return"Up"
. Otherwise, it should return"Down"
. Also, ifnext_floor
is the same ascurrent_floor
, it should return 0. Assume there are no 0 or negative floors. For example,move_elevator(5, 8)
should return"Up"
.-
Write a function called
lunch_break
that takes a parameterclass_standing
and determines how long a lunch break will be based on the student’s class standing. If a person is a ‘Freshman’, return40
. If a person is a ‘Sophomore’, return30
. If a person is a ‘Junior’, return20
. If a person is a ‘Senior’, return15
. If a person is none of these, return0
. For example,lunch_break('Alumni')
should return0
. Write a function called
pay_rent
that takes in one parameter,units
. Ifunits
is less than 200, return"$100"
. Ifunits
is less than 500 and greater than or equal to 200, return"$200"
. Otherwise, return"$300"
. For example,pay_rent(175)
should return"$100"
.Write a function called
pay_rent
that takes in one parameter,units
. Ifunits
is less than 200, return"$100"
. Ifunits
is less than 500 and greater than or equal to 200, return"$200"
. Otherwise, return"$300"
. For example,pay_rent(175)
should return"$100"
.-
Write a function called
play_weather
that takes the stringweather
as a parameter and returns if one should play or not. If theweather
is ‘sunny’ or ‘cloudy’, then the function should return"The person should play"
. If theweather
is ‘rainy’, ‘windy’ or ‘snowy’, then the function should return"The person should not play"
. If theweather
is none of these, the function should return"It is not safe to go outside"
. For example,play_weather('sunny')
should return"The person should play"
.