Day 1 || Functions part-1 ||

Python

Day 1 || Functions part-1 ||

Hello Wizards, welcome to the new tutorial on advance python. In the previous tutorial, we discussed some concepts in core python, Now help me to dive into the advance python.

Let me start with the Functions…

Function:

In simple function is piece of code that can be re-usable. There are two types of functions.

1)Built-in Functions :

Functions that are built in python like print(),file(),len(),all(),any(). There are total 67 built-in functions in python.

2)User-defined functions:

Functions that are created by the user, are called user-defined functions. These are defined according to the client (or) Business requirement.

Let me create a simple function:

1] Firstly, for creating a function we have to use “def” followed by the “Function name” and parenthesis ().

2] The code block within the function should be ended by the colon(:).

simple function

Return Statement:

By the name itself, it describes that it returns a value from a function, return statement without any expression argument returns “none”.

return

Forms of function arguments:

1] Required arguments (or) Positional arguments:

Arguments that are passed by us, should match the function parameter from the left to right.

NOTE: Here we have pass all the arguments, otherwise it gives missing argument error.

positional arguments

2] Keyword arguments:

These are some type of assigning values type arguments, specifying a keyword argument in the form of argument name = value.

key

3] Default arguments:

These type of arguments are written in the format of “argument = Value”, so we got an advantage so that we can declare (0r) not declare the value.

 

 

0 thoughts on “Day 1 || Functions part-1 ||

  1. Really appreciatable work..😊😊
    Hope u reach higher and help more students with your valuable content😊

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.