An intro to programming concepts with Scratch

Slides:



Advertisements
Similar presentations
Create a Simple Game in Scratch
Advertisements

Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
SCRATCH Lesson Two – Interactive Concepts Using Sensing, Operators, and Variables.
30 min Scratch July min intro to Scratch A Quick-and-Dirty approach Leaving lots of exploration for the future. (5 hour lesson plan available)
1 An intro to programming concepts with Scratch Session 3 of 10 sessions Repetition and variations.
Learn… Create… Program. Manipulation of Multiple Media Connects with youth culture Scratch is a new graphical programming language designed to support.
Session 5 of 10 Review + Multiple Sprites
1 An introduction to programming concepts with Scratch.
An intro to programming concepts with Scratch Session 2 of 10 sessions I/O, variables, simple computing.
1 An introduction to programming concepts with Scratch (in 5 hours + homework)
1 An intro to programming concepts with Scratch Session 1 of 10 sessions Looks and Motion.
ITEC Winter An intro to programming concepts with Scratch Quick intro for college citizens. George Stockman MSU CSE.
Madlib-Input, Strings, and Lists in Scratch Barb Ericson Georgia Tech June 2011.
Bug Session Two. Session description In this session the use of algorithms is reinforced to help pupils plan out what they will need to program on their.
Extending the Pong Example Barb Ericson Georgia Tech June 2011.
2012 CSE-BEACON camp1 Computer Science Concepts 1. What is an algorithm? 2. Binary information coding 3. Programming concepts via Scratch Designed for.
Green text p.138 #s The length of the second side of a triangle is 2 inches less than the length of the first side. The length of the third.
Scratch the Cat. Object Oriented Programing Writing computer programs Based on Objects Instead of Actions Based on Data Instead of Logic.
Microsoft® Small Basic
Section 3 Calculations National 4/5 Scratch Course.
Using MIT Scratch for Programming and Control Exercise 3 Ball Game Year 9 ICT Autumn Term 2007.
Summer Computing Workshop. Session 2 Input in Scratch  Multi-Character input - This is used when the user is prompted to enter a number or word.  Problems.
Introducing Scratch the Cat
Objects and Methods in Scratch 1. 2 Scratch environment Stage is at upper right (where actors act and information is displayed) Sprite is another name.
ACO 101 Making a program. mb_your_brain_on_improv.html mb_your_brain_on_improv.html.
How to start Visual Studio 2008 or 2010 (command-line program)
2015 CSE/EGR Summer Camps 1 Computer Science Concepts 1. What is an algorithm? 2. Binary information coding 3. Programming concepts via Scratch Designed.
Practice with Area, Perimeter and Circumference Sometimes we have to find area or perimeter of odd shapes. Find the area of the following shape. 15 m.
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.
Computer Programming Modeling a Passive Solar Home.
1 Project designed and created by M. Shajith Kumar.
Using MIT Scratch for Programming and Control Exercise 1 Creating movement Year 11 DTG 2012.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Exercise 1 #include int main() { printf(“Hello C Programming!\n”); return 0; } 1.Run your Visual Studio 2008 or Create a new “project” and add.
How to create a basic game in Scratch. The Scratch Stage The Scratch stage is 480 pixels wide and 360 pixels high x increasesx decreases.
Perimeter, Circumference and Area. Perimeter and Circumference Perimeter : The distance around a geometric figure. Circumference: The distance around.
ICT/COMPUTING RULES Only use software allowed by the teacher
Madlib-Input, Strings, and Lists in Scratch Barb Ericson Georgia Tech.
G-11 (1-5) Using formulas in Geometry I can use formulas to compute perimeter and area of triangles, squares, rectangles, and circles.
Basic Programming I Working with QBasic
Scratch Helicopter Game
Programming on the TI-84 and TI-Nspire
Create a Halloween Computer Game in Scratch
Exploring Mathematical Relationships Module 5: Investigation 1
Scratch for Interactivity
Exploring Mathematical Relationships Module 5: Investigation 3
Madlib-Input, Strings, and Lists in Scratch
Scratch Unit Overview We are going to look at computer programming and how to create your very own computer game The piece of software we will be using.
Spanish Mad libs with Scratch
Scratch for Interactivity
Introduction to Object-Oriented Programming
Creating Variables Output Logic flow Operators (More) Basic blocks
Learn… Create… Program
Module 5 Lesson 3 Extreme Scratch Cards
Motion and Looks.
Go to =>
Learn… Create… Program
Go to =>
Go to =>
Getting Started with Scratch
Game Over Module 4 Lesson 2.
Getting Started with Scratch
Learn… Create… Program
Learn… Create… Program
Creating a Simple Game in Scratch
Asking Questions in BYOB Scratch.
CSC 221: Introduction to Programming Fall 2018
Presentation transcript:

An intro to programming concepts with Scratch Session 2 of 10 sessions I/O , variables, simple computing

Session 2 goals Learn how the user and the program can communicate Learn how to compute with formulas Computing an average, perimeter of a geometric figure, etc

What is needed Students need to have computers with Scratch installed: 1 or 2 students per computer Workbook for each student Method for students to save their work

Start scratch and let’s go! Click on the cat icon If not on desktop, download from www.scratch.mit.edu Scratch programming environment comes up quickly We will first do simple ops

Getting information from the user or some other machine The SENSING menu Getting information from the user or some other machine

Asking the age of the user Program wants age of user (maybe to set a level of difficulty in a game) Program asks user for age User types in age Program stores the answer in a variable named “answer”

Use the SENSING menu Ask the user for age; 2) user types in age; 3) result stored in “answer”

User types “13” and the script stores the answer “answer” is a Special Scratch variable

OUTPUT: Giving the user information with say answer Say is in Looks menu; drag “answer” from Sensing menu; click

Using the Variables menu We can save an answer in our own named variable; Then we can program with many data items using many variables

What is your age Depends on who you are For one person it’s 12 For another person it’s 27 For yet another, it’s 19 IT’S VARIABLE!

Making an “age variable” Click Variables menu; 2) click “Make a variable” Type in “age” and click OK Do you want to display for all sprites or just one?

We have an “age variable” Operations for “age” Displaying variable “age”

We can join text and a number to say things From Looks From Operators From Sensing Make the join Build this instruction from the parts above it.

Storing a value in a variable; then saying it to the user Set from Variables menu; 2) Say from Looks menu; 3) Join from the Operators menu joins your text with the “answer”

Using variables in programs A script might have to remember information How far is the cat from the dog? How fast is the rocket moving? Where did the user click on the stage? What is my score in the game? What is the user’s skill level?

Computing C = A + B (1 of 3) Make 3 variables, A, B, and C Type in the values of A and B Set the value of C to the sum of A and B

Computing C = A + B (2 of 3) Make 3 variables, A, B, and C Type in the values of A and B Set the value of C to the sum of A and B

Computing C = A + B (3 of 3) Make 3 variables, A, B, and C Type in the values of A and B Set the value of C to the sum of A and B Drag + operator from Operators menu From Variables menu drag variables A and B into the slots

Algorithm for computing the average of two numbers Let the first number be A; say A=12 And the second number be B; say B=15 To compute the average _____________ So the average of 12 and 15 = ________

Programming the average A is the first “variable”: A = _____ B is the second “variable”: B = _____ V is the third variable: V = _____ Take the value of A, add the value of B, divide this sum by 2, then set the value of V to this answer. V = (A+B)/2 (how to do it in Scratch?)

Script from Variables and Operators menus Drag the variable names into the slots of the operators Script not yet executed A formula from the Operators menu

After clicking to execute script The variable V now stores the computed average of A and B

Exercise Put a Wait 5 secs in the script between the two set operations for variable V Execute the script and observe the changes in the value of V

Exercise Change the values of A and B by editing the script (keep the Wait); Click on your script to compute the average of the new A and B

Exercise: average program Modify the average program Ask the user for a value of A Ask the user for a value of B Compute V as the average Report the average to the user Run the program for different As and Bs

Exercises for later on 1 show how to start the program by clicking on the flag (see “Control”) 2 show how to average 3 numbers; say 12, 33, and 21

Computing perimeter of a rectangle: algorithm Ask the user for length L Ask the user for width W Compute P = (L+W)*2 Report P to the user W = 10 example L=15 P = (15+10)*2 = 50

Review: Getting length from user Drag from Sensing menu Ask “What’s the length” and wait Set length to answer Drag from sensing menu Create this variable

Review: Reporting the value of a variable to the user Looks menu You type this in Say join “length =“ length for 2 sec Drag length variable from Variables menu Operators menu

Review: Program with user input and output

Exercise: create the Scratch program we designed Ask the user for length L Ask the user for width W Compute P = (L+W)*2 Report P to the user Show your program to the instructor.

Exercises for later Write a program to ask the user for the diameter of a circle; compute and report the circumference. After completing the above, compute and report the area also Write a program to input a length in inches; report the length in centimeters. Begin your program by clicking the green flag. Get a better sprite from the sprite box. The sprite should look more like your teacher than a cat! Show your teacher your program.

Individual achievement: student creates/demonstrates Set a variable “SIDE” to have some value Sprite starts at home base at x=-100; y=-50 Sprite says “I hit the ball” for 2 seconds Sprite runs (east) SIDE steps to 1st base Sprite changes color Sprite runs SIDE steps to 2nd base (north: left turn from 1st base) Sprite doubles size Sprite says “I hit a double” for 5 seconds *Sprite reports its current X,Y coordinates

End of Session 2: outcomes Student should be able to write a program to ask the user for data, compute using the data, and report the answer to the user. Students should be able to compute using common formulas.