Section 7.8

Procedures

Learning Goals


AAP-2.A.1: An algorithm is a finite set of instructions that accomplish a specific task. 


AAP-2.A.2: Beyond visual and textual programming languages, algorithms can be expressed in a variety of ways, such as natural language, diagrams, and pseudocode. 


AAP-2.A.3: Algorithms executed by programs are implemented using programming languages. 


AAP-2.A.4: Every algorithm can be constructed using combinations of sequencing, selection, and iteration. 


AAP-2.B.1: Sequencing is the application of each step of an algorithm in the order in which the code statements are given. 

AAP-2.B.2: A code statement is a part of program code that expresses an action to be carried out. 

AAP-2.B.3: An expression can consist of a value, a variable, an operator, or a procedure call that returns a value. 

AAP-2.B.4: Expressions are evaluated to produce a single value.

AAP-2.B.5: The evaluation of expressions follows a set order of operations defined by the programming language.

AAP-2.B.6: Sequential statements execute in the order they appear in the code segment.

AAP-2.B.7: Clarity and readability are important considerations when expressing an algorithm in a programming language. 

AAP-2.G.1: Selection determines which parts of an algorithm are executed based on a condition being true or false. 


Objectives and Description

The objective of this lesson is to both introduce students to procedural abstraction, a way to generalize procedures in a way that can handle multiple different inputs (within some specified parameters). These procedures can be used throughout our code to apply them to different situations or produce different results

Activities

Activity 7.8.1 (Budget 20 minutes)

4.  Any time after you have introduced slide 6, you can begin a discussion about selection.   Use this example, Imagine you’re trying to decide what to wear for the day. You look outside and see that it’s raining. You have two options: wear a raincoat or wear a regular jacket. You decide to wear a raincoat because it will keep you dry in the rain. In this scenario, you have used selection to make a decision based on a condition (the weather).  Selection is a fundamental concept in programming, but it’s also something we use in our everyday lives. We make decisions based on certain conditions all the time, whether we realize it or not.  

Activity 7.8.2 (Budget 30 minutes)

Activity 7.8.3 (Budget 60 minutes)

Activity 7.8.4 (Bonus)