Skip to content

Spoke Right

Education for everyone

https://spokeright.com
Primary Menu
  • Home
  • Our Services
    • Translation
    • Interpretation
    • Transcription
    • Voice-Over
    • Proofreading
    • Content writing
  • Free Education
    • Learn Android Studio
    • Learn Python
    • Learn MongoDB
    • Learn MySql
    • Learn React
    • Montessori Education
  • Spoke Right News
  • Earn Online
  • Classic Games by Spoke Right
    • TicTac
    • Checkers
    • Foosball
    • Billiards
    • Master Chess
    • Logic Game
  • Contact Us
Download Now
  • Home
  • Learn Python
  • What are Python functions
  • Learn Python

What are Python functions

Spoke Right December 6, 2022 2 min read

Python function

A function is a block of code that is written once and can be executed whenever required in the program, to produce some output.

Types of Functions:

Built-in Functions:

The Python library already contains some functions that are predefined to perform a specific function. These functions are known as built-in functions.

User- Defined Functions:

Functions are often created by user itself within the code to simplify the code and to increase the code reusability. Such user created functions for code simplification are called as user-defined functions.

Creating a Python Function:

Creating or defining a python function is done by using the def keyword.

Syntax:

def function_name(parameters):

Statements

Calling a Python Function:

Writing the function name followed by parenthesis serves the purpose of function calling in Python.

Syntax:

def function_name(parameters):

Statements

function_name()

Parameters in a Python Function:

The information passed in the function definition are called as parameters. Parameters are variable in nature and can often called as formal parameters or formal arguments.

Arguments in a Python Function:

The information passed in the function call are called as arguments. Arguments be taken as literals, variables and expressions and they are often called as actual parameters or actual arguments.

Scope of a Variable in/out a Python Function:

The part of the code where a variable is accessible within the code is called as the scope of the variable.

Types of Scope of a Python Variable:

Python Local Variables:

A Local Variable is accessible only inside the function body, as it is declared inside a function body and thus have a local access only.

Python Global Variable

A Global Variable is accessible all over the program code as it is declared outside a function body and thus have a global access.

Example:

def expression(x):
return 10*(x+20)
 
print(expression(10))
print(expression(20))
print(expression(30))

Continue Reading

Previous: What is python dictionary in python
Next: What is python Files IO

Related Stories

What is Data Statistics And Analysis With Java And Python
9 min read
  • Learn Python

What is Data Statistics And Analysis With Java And Python

December 7, 2022
How do I get the date in Python
2 min read
  • Learn Python

How do I get the date in Python

December 7, 2022
What is an exception handler in Python
2 min read
  • Learn Python

What is an exception handler in Python

December 7, 2022

This AD Will support Us

Support Us

Coding Ustad LTD Support
Coding Ustad LTD Support

Coding Ustad LTD

Coding Ustad LTD
Coding Ustad LTD

Recent Posts

  • How to Install Node.js and npm on CentOS 7
  • How to Install Node.js and npm on CentOS 7
  • How to Install CentOS Web Panel (CWP) on CentOS 7
  • The Power of Marketing in Real Estate: A Guide to Boost Your Business
  • Vehicle Verification in Pakistan

Get free Hosting

Hostens.com - A home for your website

You may have missed

How to Install Node.js and npm on CentOS 7
4 min read
  • Coding Ustad LTD
  • Education for Everyone

How to Install Node.js and npm on CentOS 7

May 3, 2023
How to Install Node.js and npm on CentOS 7
4 min read
  • Coding Ustad LTD
  • Education for Everyone

How to Install Node.js and npm on CentOS 7

May 2, 2023
How to Install CentOS Web Panel (CWP) on CentOS 7
3 min read
  • Coding Ustad LTD
  • Education for Everyone

How to Install CentOS Web Panel (CWP) on CentOS 7

May 2, 2023
The Power of Marketing in Real Estate: A Guide to Boost Your Business https://thaikadar.com/secureinvestment/
2 min read
  • Article By Spoke Right
  • Blog By Spoke Right
  • Circular Byte Private Limited

The Power of Marketing in Real Estate: A Guide to Boost Your Business

January 30, 2023
  • Home
  • Our Services
  • Free Education
  • Spoke Right News
  • Earn Online
  • Classic Games by Spoke Right
  • Contact Us
Copyright © All rights reserved. | MoreNews by AF themes.