def f(x) python 1

def f(x) python

def fahrenheit(T_in_celsius):
    """ Gibt die Temperatur T_in_celsius in Grad Fahrenheit zurück """
    return (T_in_celsius * 9 / 5) + 32
for t in (22.6, 25.8, 27.3, 29.8):
    print(t, ": ", fahrenheit(t))

Here is what the above code is Doing:
1. The function definition opens with the keyword def followed by the name of the function and a parenthesized list of parameter names. The body of the function — the statements that are executed when it runs — is indented below the definition line.
2. When we call the function, the values we pass to it are assigned to those variables so that we can use them inside the function. Inside the function, we use a return statement to send a result back to whoever asked for it.
3. Defining a function does not run it. Defining a function simply tells Python that it exists. When we want to run it, we call it.
4. The return statement exits a function, optionally passing back a value. A return statement with no arguments is the same as return None.

Similar Posts