Note Template
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.
My Notes:
- A procedure call interrupts a series of statements and makes the program execute the statements in the procedure.
- After executing, it will return to the original call and finish the statements.
- In order to determine what the result of a procedure is, you need to carefully examine the code line by line
- A procedure MAY or MAY NOT return a value (a number or boolean (true or false)).
- Before we start writing the procedure, we need to know what arguments the procedures require and and what type of data the procedure will return.
- We need to be able to call the procedure.
- To call a procedure you would write the name of the procedure followed by the parentheses with the parameters of the procedure (there may not be parameters, but parenthesis must be there).
- A procedure is a named block of code that performs a specific task, but does not return a value. The procedure can be called by another part of the program. A procedure for a login menu could be written like this: Pseudocode. Python.
What are procedures?
Fill in the blanks please:
Procedure:
- A Procedure is a named group of programming instructions that may have parameters and return values.
Parameters:
- Parameters are input values of a procedure. Arguments:
- Arguments specify the values of the parameters when a procedure is called Modularity:
Procedural Abstraction:
What are some other names for procedures?:
- Procedures can also be referred as method or function, depending on the language
Why are procedures effective?:
n = int(input("Please input a number"))
def convertToBinary(n):
return (bin(n)[2:])
convertToBinary(n)
numA = int(input("Please inout a number:"))
numB = int(input("Please inout a number:"))
def findmax(numA,numB):
if numA > numB:
print("You inputed the numbers " + str(numA) + " and " + str(numB) + " out of these two numbers" + str(numA) + " is greater than " + str(numB))
elif numA < numB:
print("You inputed the numbers " + str(numA) + " and " + str(numB) + " out of these two numbers " + str(numA) + " is less than " + str(numB))
else:
print("Please input a number")
findmax(numA,numB)
I did the js version in the other link I provided
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.
text = "APCSP"
def charToBinary(text):
binary = [convertToBinary(ord(c)) for c in list(text)]
return binary
print(charToBinary(text))