GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing maker.makecode.com — Functions FunctionsFunctions are the fundamental building block of programs. Here is the simplest way to make a function that adds two numbers: Functions can refer to variables outside of the function body.
When they do so, they're said to Python can figure the return type out by looking at the return statements, so you can optionally leave this off in many cases. Optional and Default ParametersThe number of arguments given to a function has to match the number of parameters the function expects. In Python, if a parameter is optional, and users may leave them off as they see fit.
When they do, their value is Any optional parameters must follow required parameters. Had we wanted to make the first name optional rather than the last name, we would need to change the order of parameters in the function, putting the first name last in the list. In Python, we can also set a value that a parameter will be assigned if the user does not provide one, or if the user passes Default-initialized parameters that come after all required parameters are treated as optional, and just like optional parameters, can be omitted when calling their respective function. This means optional parameters and trailing default parameters will share commonality in their types, so both and share the same type Handler FunctionsHandler functions are functions that take some action when an event or change of state occurs. Usually, some other code saves, or registers, the handler function in a variable in order to call it at a later time. When an event happens, like a new input value or an elapsed timer, the handler is called to run a response action. As an example, the Lambda FunctionsLambda functions serve as a kind of shortcut to return a result of an expression. A lambda is often saved to a variable and then used like a function to return the expression result: A lambda can also be used anonymously to directly return a result.
|
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |