Function Calling Expressions

Q

How to call a function in an expression in Python?

✍: FYIcenter.com

A

To call a function and execute its statement block in an expression, you can enter the function name followed by a list of values to be assigned to parameters defined in the function.

For example, the profile("Joe",25) expression calls the "profile()" function to be executed with 2 values provided to be assigned to its parameters.

>>> def profile(name,age):
...     print("Name: "+name)
...     print("Age: "+str(age))
...
>>> profile("Joe",25)
Name: Joe
Age: 25

 

Defining Functions in Python

⇒⇒Python Tutorials

2017-09-18, 116👍, 0💬