160 likes | 262 Vues
Table of Contents. 24 Background Building 25 Computing Terminology, and Speed/Velocity 26 27 Module 4 Notes: Sensing, Or Operator, Conditional Logic 28 29 30 31 32 33 34 35 36 37 38 39. 2. Module 4 Notes: Sensing, Or Operator, Conditional Logic. Sensing.
E N D
Table of Contents 24 Background Building 25 Computing Terminology, and Speed/Velocity 26 27 Module 4 Notes: Sensing, Or Operator, Conditional Logic 28 29 30 31 32 33 34 35 36 37 38 39 2 Module 1
Sensing • These tools are used to detect something • Sprites touching sprites • Sprites touching colors • User key entries • User text entry (i.e. Module 2)
Operators: Or • We use these to help make decisions • Checks to see if something is true • Or: this checks if one condition is true OR another condition is true • We can put multiple Operators together
Conditional Logic: Wait Until • Located under Control tools • Conditional Looping: Repeat functions over and over again in your program for some desired effect. • Wait Until: keeps checking until the condition is true. Then is performs an action.
Conditional Logic: If • A type of Conditional Logic • Acalculation that uses IF-THEN-ELSE logic like in Module 3. • But this one only has IF • Your program does what ever is inside of it, IF the variable is true.
Stop Script • This tells Scratch to stop that piece of code from multitasking • If too many tools are multitasking it will slow down your computer • Stop Script stops processes (jobs) that do not need to be completed or are done
Left Side Activity 1 • Describe in detail what a normal school day is like: (answers will vary) • What major things do you always do on your own? (answers will vary) • What major things does the school make you do on a daily basis? (answers will vary, but we do daily announcements, five minutes periods, etc) • What do you do first in this formula: (3 + 4) x (2 x 4) (we want them to think of PEMDAS and the steps they follow to finish the formula) • What is a job? (answers will vary) • If we do more than one job at a time what is that called? (multitasking or parallelism)
Algorithms • A set of rules that define a sequence of steps that have to be done • This is basically what your daily schedule looks like at school. • In Math: it is step-by-step procedure for calculations like PEMDAS • In MIRD: The computer will go through steps to create some output. We program the steps in Scratch • This Algorithm will receive Yellow broadcast • Switch costumes and • The output is that it shows the costume
Functions • A function completes a job • A function completes a process • When you put multiple algorithms (steps) together they create functions • Algorithms tell how the function works • Math: a function is also a formula like the formula for speed: • Speed = Distance/Time • This function tells us how fast something goes • MIRD: our computer programs can have hundreds or thousands of functions (see next slide) • Functions use all of the tools in Scratch
Function Examples • What is this functions job? • It resets the three variables back to zero. • What is this functions job? • It tells the sprite to go to a certain XY coordinate and then glides to the coordinates given
Left Side Activity 2 • What type of jobs do computer do in our lives: (answers will vary) • What type of jobs do we want computers to do and not stop? (answers will vary, some might be sewage treatment, air traffic control, electrical plants, television stations, web servers, medical equipment, etc.) • Give an example of when you made a decision based upon another decision (start by using IF): (Give an example of your choice, here is one if you are short on time: if I won a million dollars from the lottery, then I will have to decide if I want to buy a new house or if I want to buy a fancy car or save my money; if I don’t win a million dollars then I have to decide if I will buy another lottery ticket, or if I will go find a better paying job).
Forever Loop • These control tools run Forever • They never stop unless we tell them to stop • It keeps running our function by starting over after it completes it • We will use Forever to check if we are touching another sprite • In our program we will need to forever to keep checking if the finish line is touching the winning sprite
Embedded IF/ELSE conditions • Embedded means something is inside of something else • A hamburger is embedded within a bun • We embed IF/ELSE conditions to make multiple decisions • Think of our examples from the left side 2 • A decision based upon another decision • Conditional Logic: a condition based upon another condition Example • If: touching Sprite 2: Turn right 15 degrees • Else: If: touching Sprite 3: change color effect • Else: say “I’m touching nothing”