• A procedure is a named set of instructions that can take in parameters and return values.

    • May be called "method" or "function" in different programming languages.
  • Parameters are independent variables used in the procedure to produce a result. It allows a procedure to execute without initially knowing specific input values.

  • Procedures can be classified as sequencing, selection, and iteration. How?

x = 5
y = 3

def multiply(x, y):
    product = x * y
    return product

answer = multiply(x, y)
print("The product of", x, "times", y, "is", answer)
The product of 5 times 3 is 15

In this case, above in the code, multiply() is what is called the procedure because it is what performes the function and x and y are the parameters because they are the variable being used by the procedures.

num = 5
def math(x):
    op1 = x * 2
    op2 = op1 - 9
    return op2

Return calls back the procedure output and makes sure that the program keeps running

def function(first_name, last_name):
   print(first_name + " " + last_name)

function("Peter","Parker")
function("Safin", "Singh")
Peter Parker
Safin Singh

It is kind of like a more complicated version of printing parameters and in this way, you don't have to assign a variable to the value.

import math

values = [4, 9, 16, 25, 36, 49]

squareroots = [math.sqrt(number) for number in values]

print("The Original Values:\n", values)
print("The Square Root Values:\n", squareroots)
The Original Values:
 [4, 9, 16, 25, 36, 49]
The Square Root Values:
 [2.0, 3.0, 4.0, 5.0, 6.0, 7.0]

This is a way to efficiently take the square root of multiple values at once instead of writing seperate code for each of them and I thought that was really cool and saved a lot of time.