Algorithms Writing instructions in the order they should execute.

Slides:



Advertisements
Similar presentations
GAME:IT Junior Learning Game Maker: The Control Tab.
Advertisements

Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
RAPTOR Syntax and Semantics By Lt Col Schorsch
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
Mr. Wortzman INTRO. TO COMPUTER SCIENCE. UNIT 1 – CUSTOM BLOCKS.
ITEC113 Algorithms and Programming Techniques
CS001 Introduction to Programming Day 3 Sujana Jyothi
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
CS107 Introduction to Computer Science Loops. Instructions Pseudocode Assign values to variables using basic arithmetic operations x = 3 y = x/10 z =
Introduction Chapter 4: Control structures. Introduction to OOPDr. S. GANNOUNI & Dr. A. TOUIRPage 2 Objectives What are control structures Relational.
1 An introduction to programming concepts with Scratch.
ACSE th Conference The Iconic Programmer Stephen Chen.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
While Loops and Do Loops. Suppose you wanted to repeat the same code over and over again? System.out.println(“text”); System.out.println(“text”); System.out.println(“text”);
Shorter of two objects and changing color Functions, events and setting the color Susan Rodger, Duke University June 2008.
Summer Computing Workshop. Session 4 Loops  At the heart of their functionality, loops enable blocks of code to be executed more than once  Loops represent.
This will let you see the game you are going to play on the inside. It will help you see what all goes into creating instance to that goes into setting.
Ms. Deveny Second Semester  Introductions  Interview your table partner  Name  Why taking CPD  Computer experience  Favorite game?
CS0004: Introduction to Programming Relational Operators, Logical Operators, and If Statements.
Flow of Control. 2 Control Structures Control structure: An instruction that determines the order in which other instructions in a program are executed.
Programming & Scratch. Programming Learning to program is ultimately about learning to think logically and to approach problems methodically. The building.
Introducing Scratch the Cat
PAGES:51-59 SECTION: CONTROL1 : DECISIONS Decisions.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
Module 3 Fraser High School. Module 3 – Loops and Booleans import statements - random use the random.randint() function use while loop write conditional.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
2015 CSE/EGR Summer Camps 1 Computer Science Concepts 1. What is an algorithm? 2. Binary information coding 3. Programming concepts via Scratch Designed.
PHP Logic. Review: Variables Variables: a symbol or name that stands for a value – Data types ( Similar to C++ or Java): Int, Float, Boolean, String,
By Melissa Dalis Professor Susan Rodger Duke University June 2011 Multiplication Table.
Scratch Programming Lesson 4 Question asking and answering.
Control Structures II Repetition (Loops). Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1.
ITEC113 Algorithms and Programming Techniques
1 ball, 2 ball, red ball, blue ball By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Variables. Todays Lesson  In todays lesson you are going to:  Learn to use variables  Learn to ask for user input  Learn to save the users response.
CONTROL FLOW The order in which blocks are executed is called the “control flow” of the script So far all our scripts have just executed blocks in the.
TRIGGERS Triggers tell a script to start executing There are four types of triggers: When green flag is clicked When I am clicked When is pressed When.
Summer Computing Workshop. Session 3 Conditional Branching  Conditional branching is used to alter the normal flow of execution depending on the value.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008.
Basic Conditions. Challenge: ● Ask the user his/her name ● If it’s “Wally,” jeer him ● Pause video and try on your own.
Getting started with the turtle Find the latest version of this document at
CompSci 4 Chap 6 Sec 2 Sep 30, 2010 Prof. Susan Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were not a Flutterbudget.
Scratch for Interactivity Dr. Ben Schafer Department of Computer Science University of Northern Iowa.
Computer Science 1000 Algorithms III. Multiple Inputs suppose I ask you to write a program that computes the area of a rectangle area = length * width.
IST 210: PHP LOGIC IST 210: Organization of Data IST210 1.
Chapter Six. Exercises Clear the screen Write a procedure to show a symbol at (dl, dh). AL stores the symbol. Write a procedure to control a character.
Conditionals.
Introduction to Scratch We will be using the Scratch Environment today, so please log in to the Scratch website (scratch.mit.edu)
Python Programming Module 4 Sensors and Loops Python Programming, 2/e1.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
Functions / Blocks.
Scratch for Interactivity
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
Understanding the Geometric Shape Code
Diamond Hunt Mock Programming Project.
Microsoft Visual Basic 2005 BASICS
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Introduction to TouchDevelop
JavaScript What is JavaScript? What can JavaScript do?
Selection Statements.
Mod 2 Lesson 2 Repeating with loops
JavaScript What is JavaScript? What can JavaScript do?
ICT Gaming Lesson 3.
Using Logo and Logic This presentation uses a version of Logo called StarLogo available through MIT. It can be downloaded for free and installed on your.
Flow of Control.
Relational Operators.
IAT 800 Foundations of Computational Art and Design
Presentation transcript:

algorithms Writing instructions in the order they should execute

Creating a method Exercise 1 Move the sprite 25 steps, Have the sprite say your name for 3 seconds Turn the sprite around and move it back where it came from Have the sprite say “I love BYOB!” for 5 seconds Some commands require additional information to execute. pointInDirection(90); 90 is the argument (value) The are where you put arguments is called parameter( );

Drawing Exercise 1: Write an algorithm to make your sprite draw a square with 50 step sides. Exercise 2: Once you’ve done that, write an algorithm to draw two squares next to each other The squares should not be connected by a line

Sequence Exercise: Rewrite your square drawing algorithm to draw a square whenever the space bar is pressed. Clear the screen before each new square.

User Interaction Exercise: Write scripts to allow the user to move a sprite around the stage with the arrow keys.

Loops Repeated Instructions Exercise 1: Rewrite the script to draw a square using loops. Try not to repeat any code. Exercise 2: Now rewrite the script to draw two squares next to each other using loops. Again, try not to repeat code. This is tricky!

User Input Exercise 1: Write an algorithm to do the following: Ask the user for a number between 1 and 10 Draw that many squares Exercise 2: Write an algorithm to do the following: Ask the user for a number between 1 and 10 Ask the user for a number between 1 and 255 Draw the first number of squares with the pen color set to the second number

Color Color has values between 1 and 255 RGB Model for color Color(r,g,b) Color(255,0,0) red Color(0,255,0) green Color(0,0,255) blue

Creating Variables Variables store information that can change. Create the variable Must set the variable to some amount Assign the variable new information

Color Exercise 2: Write an algorithm to do the following: Ask the user for a number between 1 and 10 Ask the user for a number between 1 and 255 Draw the first number of squares with the pen color set to the second number

Arithmetic Operators Exercise: Write an algorithm to do the following: Ask the user for a number between 1 and 5 Draw twice that many squares

Boolean expressions evaluate to either true or false Relational Operators They show a relation between 2 things. 6 < 7 5 > 4 25 == 7 72 <= 52 They are used in conditionals to execute either the if or the else part of nothing.

Boolean Expressions ANDTF TTF FFF ORTF TTT FTF NOT TF FT Compare two complete conditions Draw a square and a rectangle. --- Must do both AND Draw a square or a rectangle -- Can do either OR Draw a square or a rectangle (NOT)

Conditionals – Booleans Random Exercise 1: Write an algorithm to do the following: Generate a random number between 1 and 10 Draw a red square if the number is less than 6 Draw a blue square if the number is 6 or greater Exercise 2: Write an algorithm to do the following: Generate two random numbers between 1 and 10 If both are less than 6, draw a red square If both are 6 or greater, draw a blue square Otherwise, draw a purple square Relational Operators Greater than > Less than < Equal to == >= <=

Project: Create an algorithm that will generate a random number and say the number and whether it is even or odd. If the random number is even it will say the random number and I am an even number. If it is odd it will say the random number and I am odd Procedure: 1.Create a variable called random 2.Set the random variable to a random number using the random operator 3.Check to see if it is even or odd by creating if statements and using the modulus operator. 4.Create if statements that You will need to use the modulus operator to see if the number is even or odd. 5.Copy your code into a word document.

Create a Guessing Game Create the Algorithm You will need to create two variables. guess randomNumber Use the random number generator from operators group