In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "the definition, characteristics and skills of Python function". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Function characteristics
Hide the details of implementing the function
Reuse code
Improve readability and facilitate debugging
Definition of function
Def function name (formal parameter 1, formal parameter 2,... Parameter n):
Code to run (function body)
Data output by return (return value)
Formal parameters: the format data specified by the function is required for constraints.
Actual parameters: the actual call to the incoming data. Used to pass values.
Return value: the calculation result of the function
After the return statement is executed, the program interrupts execution. The return value None indicates that it does not exist.
The skill of using function
The default value is function (a _ memory b = "usb", c)
Pass parameters in the form of formal parameters: func (name= "zhangsan", age=32) does not have to pass parameters according to the order of formal parameters.
* parameters after representation must be passed by keyword (name,*,age,height) [mixed format]
Sequence pass parameter l = [1 print (* 1)] (calc (* 1)
Dictionary parameter para= {"name": "zhangsan", "age": 32} health_ch (* * para)
The return value contains multiple data
Dict= {"eployer": [{"id": 134, "name": "zhangsan"}],. } name=dict.get ("employer") [0] .get ("name")
Pass parameters in tuple (* tuple)
Random number
Import random import import module
A collection of functions of a module.
Generate a random integer r=random.randint between 1 and 16 (1pc16)
This is the end of the content of "definition, characteristics and skills of Python function". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.