Take some additional notes that you would like here for 3.12 and 3.13. We will be looking for additional notes from the presentation.

What are procedures?

Fill in the blanks please:

Procedure: a named group of instructions that have paramaters and return values

Parameters: input values of a procedure

Arguments: specify values of the paramaters when the procedure is called

Modularity: An splitting large procedures into smaller ones with more uses

Procedural Abstraction: name for a process that allow a procedure to be used by only knowing what it does

Return: sends the output of the procedure to where it was called

What are some other names for procedures?: functions

Why are procedures effective?: procedures make code more effective and efficient by reducing the time to write code.

Challenge 1 below: Add the command that will call the procedure.

def DecimalToBinary(num):
    strs = ""
    while num:
        # if (num & 1) = 1
        if (num & 1):
            strs += "1"
        # if (num & 1) = 0
        else:
            strs += "0"
        # right shift by 1
        num >>= 1
    return strs
 
# function to reverse the string
def reverse(strs):
    print(strs[::-1])
 
# Driver Code
num = 67
print("Binary of num 67 is:", end=" ")
reverse(DecimalToBinary(num))
Binary of num 67 is: 1000011

Challenge 2 below: Complete the Min and Max procedure in either JavaScript and Python using the instructions from the JavaScript page. (JavaScript will get you a extra 0.1)

function min(numa, numb) {
    if(numa>numb){
        console.log(numa+" is the larger number")
    } else{
        console.log(numb+" is the larger number")
    }
    
}
a = 5
b = 2
min(a,b);
5 is the larger number

Homework/Hacks: For the hw, you have two options, easy or hard. The easy hack is for a 2.7 + extra work for the full 3. The easy hack is simply creating your own procedure with your own creativity. Since there is a lot of leeway for this one, you must do additional work to get a 3. For the hard hack, below is the start to a character to binary convertor. This is just a template, but the goal is to translate "APCSP" into binary. You can delete the existing code if you want. The only contraint is that you must use a procedure. Doing this will get you a 3.

import sys as s
def organise():
    print("What would you like to organise")
    ask = input()
    if ask=="nothing":
        s.exit()
    elif ask=="something":
        while ask != "stop":
            ask = input()
            if ask!="stop":
                print(ask)
    else:
        print("Excuse moi?")
organise()
    
What would you like to organise
math
science