Bioinfo Lab

Bioinformatics Laboratory at BiUH.

Core Values: Respect, Reflection, Communication, Commitment.

Main Page   |   Util & Src   |   Contact


Loading......

Password

Function & Module

  • The three basic components of a function are the def statement, the code block that performs the action, and the optional return value.

  • Parameters make functions more flexible, allowing different values to be passed to change the function’s behavior.

  • Modules are like sound libraries in games, organizing related functionalities together and calling them via the import statement.

  • Creating modules allows code to be divided into reusable parts for easier management and maintenance.

  • Functions can have parameters, and the order of parameters is important.

  • Functions can return values using the return statement.

  • Functions can have no parameters or multiple parameters.

  • Positional arguments and keyword arguments are two ways to pass parameters, with keyword arguments improving code readability.

  • Default parameter values can be specified in the function definition, allowing the parameter to be omitted during the call.

  • Variable scope is divided into global and local variables, with local variables only being valid within the function and global variables modifiable inside the function using the global keyword.

  • Python provides various methods for importing modules, including full module import (import math) and specific function import (from math import pi).

  • The Python standard library offers many useful modules, such as math, random, and time.