Categories
Development Python

Return value homework in Python

Write a function that returns the type of clothing you should wear, based on the parameter temperature. If the temperature is below -10, you will wear a parka and toque (return “parka and toque”). If the temperature is between -10 and 0, wear a toque (return “toque”). If the temperature is greater than 0 but less than 10, wear a sweater (return “sweater”). If the temperature is between 10 and 20, wear a t-shirt (return “t-shirt”). If the temperature is greater than 20, wear shorts (return “shorts”).

For example:

wear_the_right_thing(25) == "shorts"

wear_the_right_thing(-25) == "parka and toque"

wear_the_right_thing(-5) == "toque"

here is my code:

def wear_the_right_thing(temperature):
    if temperature < -10:
        return "parka and toque"  
    if temperature >= -10:
        return "toque"
    if temperature > -10 and temerature <= 0:
        return "sweater"
    if temperature > 10 and temperature <= 20:
        return "t-shrit"
    if temperature > 20:
        return "shorts"

Here is my result (not the output this just my marked):

Result  Actual Value    Expected Value  Notes
Fail    'toque' 'shorts'    wear_the_right_thing(25)
Fail    'toque' 't-shirt'   wear_the_right_thing(20)
Fail    'toque' 't-shirt'   wear_the_right_thing(15)
Fail    'toque' 't-shirt'   wear_the_right_thing(10)
Fail    'toque' 'sweater'   wear_the_right_thing(9)
Fail    'toque' 'sweater'   wear_the_right_thing(1)
Pass    'toque' 'toque' wear_the_right_thing(0)
Pass    'toque' 'toque' wear_the_right_thing(-10)
Pass    'parka and toque'   'parka and toque'   wear_the_right_thing(-11)
Pass    'parka and toque'   'parka and toque'   wear_the_right_thing(-30)
You passed: 40.0% of the tests

so i fail the test so can help me to get 100 thank you very much

Leave a Reply

Your email address will not be published. Required fields are marked *