Fundamental Concepts in Python

  • By Deepali Shinkar
  • September 7, 2023
  • Python
Fundamental Concepts in Python 

Fundamental Concepts in Python 

In python, a function is a block of reusable code that performs a specific task or set of tasks. Function allow you to break your code into smaller  more manageable pieces, making it easier to understand and maintain. In this blog, you will get Fundamental Concepts in Python provides many built in functions such as  print(),input(),len(),max(),min() etc. But you can also create your own custom function to encapsulate functionality. 

For Free, Demo classes Call: 02071171500

Registration Link: Click Here!

Functions having two parts: 

1.Function Definition 

2.Function call 

Defining a function 

To define a function in python, you use the def keyword, followed by the  function name and a pair of parentheses. 

We can write function two ways: 

1.Function without arguments 

2.Function with arguments 

1.Function without arguments

Note: Unlock endless possibilities and boost your career prospects with SevenMentor’s best Python Course in Pune

Function definition : 

Syntax: 

def function_name():

function body

Function call

function_name()

In Python a function is defined using the def keyword. To call a function,  use the function name followed by parenthesis. 

Fundamental Concepts in Python 

 

Arguments 

Information can be passed into functions as arguments. 

Arguments are specified after the function name, inside the parentheses.  You can add as many arguments as you want, just separate them with a  comma. 

Fundamental Concepts in Python 

 

For Free, Demo classes Call: 02071171500

Registration Link: Python Training in Pune!

 

Default arguments 

A default argument is an argument that assumes a default value if a value  is not provided in the function call for that argument.

Fundamental Concepts in Python 

 

Arbitrary arguments 

Arbitrary arguments are used when you want the function to take an  unlimited number of arguments. When you add an asterisk ( * ), it will receive a tuple of arguments. 

Fundamental Concepts in Python 

 

Keyword arguments 

You can pass the arguments in a non-positional manner using keyword arguments.

Fundamental Concepts in Python 

 

The Return Statement  

To return a value from a function, we use a return statement. It  “returns” the result to the caller. 

A function always returns a value. If a user doesn’t include a return statement, it returns None. 

Fundamental Concepts in Python 

 

Types of variables in used Defined Function: 

Local Variable: 

A local variable that is declared inside the function is called local function”. We can access a local variable inside but not outside the  function.

Fundamental Concepts in Python 

 

For Free, Demo classes Call: 02071171500

Registration Link: Click Here!

 

Global Variable 

Variables that are created outside of a function are known as global  variables. Global variables can be used by everyone, both inside of  functions and outside. 

Python global keyword allows the user to define a variable globally  whose value can be modified outside the current scope.

Fundamental Concepts in Python 

 

Do visit our Python Video: Click Here

Conclusion 

Any programming language must contain functions. A function in Python can take any number of arguments and is defined by the def keyword.  Anonymous functions are also supported by Python. They can either provide a single value or several values one by one.

Author:-
Deepali Shinkar
Call the Trainer and Book your free demo Class For Python

Call now!!! | SevenMentor Pvt Ltd.

© Copyright 2021 | SevenMentor Pvt Ltd.

Submit Comment

Your email address will not be published. Required fields are marked *

*
*