vendredi 31 janvier 2020

I need to retrun srings based on temperature

If the temperature is 100 or above, the functions return “It is hot.”;

If the temperature is between 70 and 100, the function returns “It is warm.”;

If the temperature is between 32 and 70, the functions return “It is cool.”;

If the temperature is below 32, it returns “It is cold.”

The function feelTemp will take one value for the temperature, and then returns a category as a string.

When running the program, the user is prompted to input a temperature, then the program print one of the four categorical levels (hot, warm, cool, and cold) that the given temperature falls into.

I have tried this but getting an error in syntax.

What should I do?:

def feelTemp(t):
    if t<=100:
        return "It is hot."
    elif t>=70 and t<=100:
        return "It is warm."
    elif t>=32 and t<=70:
        return "It is cool."
    else:
        return "It is cold."
feelTemp(105)

And how to set an input field as well?

Aucun commentaire:

Enregistrer un commentaire