Tuesday, March 5, 2019

Function Junction

Function Junction

What I did today...
Functions are defined with three components:
1. The header, which includes the def keyword, the name of the function, and any parameters the function requires. 
2. An optional comment that explains what the function does.
3. The body, which describes the procedures the function carries out. The body is indented, just like conditional statements.
Example:
Notes: This can be used to solve math questions too.
Type 1:
 Steps: 1. Give instructions ahead using:
def __1__(_2_,_3_ ):
   """__"""
Print "%d to the _1_ of %d is %d." %(_2_, _3_, result)
 Step 2: 
__1__(_2_,_3_) plug in the numbers in 2 & 3.

Type 2:
Instructions given:

Type 3:
There is a Python module named math that includes a number of useful variables and functions, and sqrt() is one of those functions. In order to access math, all you need is the import keyword. When you simply import a module this way, it's called a generic import.
from math import sqrt
type sqrt() to get the square root of a number
The max() function takes any number of arguments and returns the largest one. 
Same with min()
The abs() function returns the absolute value of the number

What I learned today...
   I learned how to use Python Language to do different kinds of math. Steps are listed above. This lesson is really useful for software designers and online architecture designers. As this will accurately shows the math of the numbers, no matter how big the number is.
What I'll be doing tomorrow...
  I will be moving onto the next lesson tomorrow. The next lesson is more about the use of the Python Language that I learned from the past few days. This lesson is using Python Language to look up things in the dictionaries and go through lists.

No comments:

Post a Comment