Module 2: Jump in Python Statements - Functions


Slides
Video Lecture

Tipping Points

  • Programming language consits of language statements. A statement is sometimes called a command. Both language commands and statements are those some developers implemented, and they are those we are using. A statemet takes zero or more parameter and returns zero more values. So, it is called a function or a method. Python methods or functions are in three categories:
    • Built-in function
    • Function associated with modules that come with Python
    • Function associated with modules that should be downloaded
    • Functions that can be implemented by you when you creat a Python module
  • The built-in functions can be found from
    • help() in Python user-interactive mode
    • the webpage, here
  • For the functions associated with a module,
    • the module should be imported first. For example, the module math can be imported by
                    import math
                 
    • the function can be executed by the dot notation. For example, the method sqrt() can be executed by dot notation, e.g., math.sqrt(x), where x is a number. More specificially, the square root of 9 can be computed by:
                    math.sqrt(9)
                 
  • A module can be downloaded by the program called pip. For example, a package called datetime can be installed by
                  pip install datatime