
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Calling a Function in Python
Defining a function only gives it a name, specifies the parameters that are to be included in the function and structures the blocks of code.
Once the basic structure of a function is finalized, you can execute it by calling it from another function or directly from the Python prompt. Following is the example to call printme() function −
#!/usr/bin/python # Function definition is here def printme( str ): "This prints a passed string into this function" print str return; # Now you can call printme function printme("I'm first call to user defined function!") printme("Again second call to the same function")
Output
When the above code is executed, it produces the following result −
I'm first call to user defined function! Again second call to the same function
- Related Articles
- Calling a member function on a NULL object pointer in C++
- Calling an ABAP Function Module using Python script to put data in SAP HANA
- Calling NOW() function to fetch current date records in MySQL?
- How to prohibit a Python module from calling other modules?
- Getting Error while calling XBP Function Module via SAP.net connector
- Set a default value for the argument to cover undefined errors while calling a function in JavaScript
- How to suspend the calling thread for few seconds in Python?
- Calling a method using null in Java\n
- C++ Program to find number of calling person pairs are calling
- Calling a JAVA method through JavaScript in SAPUI5 project
- Google Duo – A Revolutionary Video Calling App
- Defining a Function in Python
- Calling virtual functions inside constructors in C++
- How can a Python function return a function?
- Calling asynchronous code from index.html page in JavaScript?

Advertisements