1 / 16

Python Function

Python main function. Main function is the entry point of any program. But python interpreter executes the source file code sequentially and doesn't call any method if it's not part of the code. But if it's directly part of the code then it will be executed when the file is imported as a module.

aliyamanasa
Télécharger la présentation

Python Function

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Python Functions

  2. Table of Contents • What is a function in Python? • Syntax of Function • Example of a function • How to call a function in python? • Docstring • The return statement • Syntax of return • Example of return • How Function works in Python? • Scope and Lifetime of variables • Types of Functions

  3. What is a function in Python? • Python, work is a group of private sector executives. • Help with exercise to break into smaller and similar programs. As our program has grown a lot, the job creates a more manageable system. • In addition, repairs are avoided and make them recyclable. • Python Interview Questions & Answers.

  4. Syntax of Function deffunction_name(parameters):           """docstring"""           statement(s) • Python training institute in Chennai

  5. The definition of the definition above is shown in the following sections. 1. The key word of the TKR is a sign of the beginning of a leader. 2. Name of activity to identify inappropriately. The name of the job is the same as Python's writings. 3. A guide (a reason) used for the cost of performance. They prefer. 4. Time (:) to show the end of the leader. Python training in Pune

  6. Example of a function: def greet(name):           """This function greets to           the person passed in as           parameter"""           print("Hello, " + name + ". Good morning!") • Python Online Training

  7. How to call a function in python? When we have a specific task, we can call other programs or even call Python. To call the action you have to write the name of the job, according to the boundaries. >>> greet('Paul') Hello, Paul. Good morning! Python tutorials

  8. Docstring: • The first presidential chain of chain of documents and chains of chains. It is used to describe a few words, what's working at the wedding. • While selecting, the documents are a good program. Apart from where to find it was the first night, always write your number. For example: Try to keep the bottom of the waste, Python watching out. >>> print(greet.__doc__) This function greets to           the person passed into the           name parameter

  9. The return statement: After this, it is used to leave the work and return to the place known. Python interview questions and answers

  10. Syntax of return: return [expression_list] This text may include quantitative expressions and return values. If there are no details on the identification or proof it is not working, then the task will return to the item. For example: >>> print(greet("May")) Hello, May. Good morning! None Python training in Bangalore

  11. Example of return: defabsolute_value(num):           """This function returns the absolute           value of the entered number"""   if num >= 0:                    return num           else:                    return -num  # Output: 2 print(absolute_value(2))  # Output: 4 print(absolute_value(-4))

  12. How Function works in Python?

  13. Scope and Lifetime of variables: • The size of a part of the program depends on the known changes. Articles and trends are defined in an unprecedented act. Therefore, they have a place to live. • A period of change in your life using a set of variables. Changing the life of the task during the operation is carried out. • When it is broken, let's go back to the action. Therefore, the action does not tell the cost of the old call.

  14. Below is an example showing the effectiveness of the work. defmy_func():           x = 10           print("Value inside function:",x)  x = 20 my_func() print("Value outside function:",x) Output:  Value inside function: 10 Value outside function: 20

  15. Types of Functions: • Basically, we can divide up two types of the following activities: • 1. Build up activities - jobs built for Python. • 2. Operations defined in the user - activity defined in the user.

  16. Thank u https://www.besanttechnologies.com/training-courses/python-training-institute-in-chennai

More Related