Skip to main content

Python Function calls

Here is example of  function call:
> type(56)
<class 'int'>
The name of the function is type. The expression in parentheses is called the argument of
the function. The result, for this function, is the type of the argument.
It is common to say that a function “takes” an argument and “returns” a result. The result
is also called the return value.
Python provides functions that convert values from one type to another. The int function
takes any value and converts it to an integer, if it can, or complains otherwise:
> int('56')
56
>int('Hello')
ValueError: invalid literal for int(): Hello
int can convert floating-point values to integers, but it doesn’t round off; it chops off the
fraction part:
>>> int(5.9999)
5
>>> int(-5.3)
-5
float converts integers and strings to floating-point numbers:
> float(56)

56.0
> float('6.24158')

6.24158

Comments