# UNIT 2 AP Computer Science Principles 2 1

• Slides: 12

UNIT 2 AP Computer Science Principles 2. 1 & 2. 2 Mr. Rigal

Unit 2: Programming - Lecture 1 DEFINING SEQUENCING APPLYING SEQUENCING

Programming ■ Algorithmic Logic Structures – 1. sequencing – 2. selection – 3. iteration ■ We are going in-depth with each of these structures throughout unit 2.

Sequencing ■ An algorithmic structure where all instructions are performed in order and executed one at a time. ■ The simplest structure of algorithms. Each step will follow the previous step. Algorithms must be completed in the order specified.

Examples ■ We examined several examples in Unit 1 – Recipes – Driving to work or school – Putting on clothes ■ Now, we are going to examine how to structure a sequence in programming.

Sequencing in Programming ■ The computer will run code in order, one line at a time from the top to the bottom of your program. – No line will be skipped unless it is commented out of the code sequence. ■ Sequences can be visualized prior to writing out your code using flowcharts, which are simple diagrams with symbols showing the flow of a process. ■ Flowcharts are not exclusive to programming – Help with visualizing steps to a process.

Oval (Terminal): used to represent start and end of a process. Rectangle (Process): represents any step in the process. Arrow (Flow Line): used to guide the viewer along the path. Diamond (Condition): indicates a decision is required to move forward. Could be a binary/Boolean decision, or a more complex one with multiple choices. Rhombus (Input/Output) : indicates input/output data being added or pulled from the flow. Common Flowchart Symbols

No Start Don’t bring umbrella Raining? Yes Find umbrella Umbrell a Bring Umbrella End FLOWCHART EXAMPLE

2. 1 Key Terms ■ algorithm: a process or set of rules to be followed in calculations or other problems solving operations ■ sequencing: logic structure where instructions are executed in order, one after another, one at a time. Often called linear. ■ flowchart: a simple diagram with symbols showing the "flow" of a process ■ flow pattern: pattern that can emerge when data is transformed using computational logic structures (sequencing, selection, iteration). ■ sequential execution: program instructions that are executed one at a time, in order.

Applying Sequencing ■ Now, we will apply sequencing in Scratch programming. ■ Complete the Try It Out – Motion section of the 2. 2 lesson on Edhesive. ■ – You will be combining different motion and sound blocks on your sprite code. – Hypothesize and test out what different sequences of the same code will do to your sprite. Incorporate comments into your code, which act as documentation. These comments can help you organize your code and assist in minimizing the debugging process. ■ Comment example

2. 2 Key Terms ■ code segment - refers to a collection of program statements that are part of a program. ■ program -a collection of program statements that performs a specific task when run by a computer. A program is often referred to as software. ■ sequencing: logic structure where instructions are executed one at a time, in order. Often called linear. ■ parameter: a variable that defines a procedure or sets the conditions of an operation ■ procedure: a named collection of steps in an algorithm that can be reused anytime it is needed without restating the detailed procedures (abstraction) ■ comments: an annotation in the code of a computer program ■ remix: to modify and share a version of an uploaded existing project

Classwork ■ 2. 1 – AP Multiple Choice Practice ■ 2. 2 – 2. 2 Exercise – AP Multiple Choice Practice