Difference between revisions of "Python: def"

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
(20 intermediate revisions by the same user not shown)
Line 1: Line 1:
<code>def</code> keyword to define a [[Python]] [[function]]
+
{{lowercase}}
 +
<code>def</code> [[keyword]] to define a [[Python]] [[function]]
 +
* https://docs.python.org/3/tutorial/controlflow.html#defining-functions
  
  
*<code>def [[lambda_handler]](event, context):</code>
+
* <code>def [[lambda_handler]](event, context):</code>
 +
 
 +
 
 +
Define it:
 +
def YourFirstFunction():
 +
    [[print]] ("My first function")
 +
 
 +
Use to execute it:
 +
YourFirstFunction()
 +
 +
 
 +
 
 +
def main():
 +
    # my code here
 +
 +
[[if __name__ == "__main__":]]
 +
    main()
 +
 
 +
== Related terms ==
 +
* [[Variables]]
 +
* <code>[[return]]</code>
 +
* <code>__[[init]]__</code>
 +
* <code>[[Python classes|class]] your_first_class:</code>
 +
* <code>[[try:]]</code>
 +
* <code>[[if name == " main ":]]</code>
  
 
== See also ==
 
== See also ==

Revision as of 20:35, 28 March 2022

Advertising: