1 / 23

Introduction to Programming G50PRO University of Nottingham Unit 2 : Introduction To Scratch

Introduction to Programming G50PRO University of Nottingham Unit 2 : Introduction To Scratch. Paul Tennent http://paultennent.wordpress.com/G50PRO.html paul.tennent@nottingham.ac.uk Room C41. What is Scratch?.

Download Presentation

Introduction to Programming G50PRO University of Nottingham Unit 2 : Introduction To Scratch

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to ProgrammingG50PROUniversity of NottinghamUnit 2 : Introduction To Scratch Paul Tennent http://paultennent.wordpress.com/G50PRO.html paul.tennent@nottingham.ac.uk Room C41

  2. What is Scratch? • Scratch is a free programmable toolkit that enables users to create games, animated stories, and interactive art • Enables users to share programs over the Internet • Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab, with funding from the National Science Foundation, Microsoft, Intel Foundation, Nokia, and the MIT Media Lab research consortia.

  3. Getting Started With Scratch • Open new project • Choose, create or edit your Sprite • Choose your background • Write your program

  4. Programming In Scratch • Click on the sprite you want to program, and select the “Scripts” tab. • The Scripts area is where you “build” your program by using the programming blocks. • In the upper, left-hand corner of your Scratch window, you will see 8 buttons . • Each of these buttons have programming blocks in those particular areas.

  5. Programming In Scratch • To program a sprite, drag blocks from the Blocks Palette to the Scripts Area. To run a block, click on it. • Create scripts (programs) by snapping blocks together into stacks. Click anywhere on the stack to run the whole script, from top to bottom

  6. Scratch Stage • The Scratch stage is 480 pixels wide and 360 pixels high. 180 240 -240 -180

  7. Scratch Blocks • Motion • Animate sprites • Control and Sensing • controls how many times an event happens, how long an event happens, or when an event happens. • conditional statements (“if statements” or “if-else statements”) • Write code so that if the user presses the Space key on the keyboard, the sprite will move 20 steps and change direction.

  8. Scratch Blocks • Sound • Looks • Pen • Operators • Variables

  9. Starting From Scratch • Scratch has all of the common elements used in all programming languages. • Conditional statements • Loops • Variables • Events

  10. START Is kettle full? Fill kettle no yes Boil Kettle Branching (Conditional Statements) Make Tea

  11. Conditional Statements • If [Boolean] • Then • Do this • Else • Do the other

  12. Comparisons • == Equals • < Less than • > More than • <= Less than or equal to • >= Greater than or equal to • != Not equal to

  13. Loops • Simplify the coding of repetitive tasks • Giving the people in a company a 10% rise • Employee 1 salary = 1.1*Employee 1 salary • Employee 2 salary = 1.1*Employee 2 salary • … • Employee 99 salary = 1.1*Employee 99 salary

  14. Loops • Simplify the coding of repetitive tasks • Giving the people in a company a 10% rise • For i = 1 to 99 • Employee i salary = 1.1*Employee i salary

  15. Loops • There are a lot of different standard types of loop • Scratch only has some of them

  16. Flow control • Flow control • In computer science flowcontrol refers to the order in which the statements or instructions are executed or evaluated. • Branches (Conditional Statements) • Loops

  17. Variables • a variable is a facility for storing data • One of the most powerful features of a programming language is the ability to manipulate variables. • A variable is a named location that stores a value. • Values are things that can be printed, stored or operated on. (numbers, letters, Strings, etc.)

  18. Variables • each variable will have • Name • Value • Location in memory X = 100 Y = 20

  19. Assignment statement Declare str str = “Hello” the idea is straightforward: • When you declare a variable, you create a named storage location. • When you make an assignment to a variable, you give it a value.

  20. BankBalance Payment 700 700 Check Balance 700

  21. Events • You can’t run all of the elements of a program at once • Things happen when the relevant event triggers them • The main event in Scratch is the green flag • There are other custom events that you can add

  22. Summary • Scratch Programming Blocks • Conditional Statements allow us to make decisions about what to do next • Loops allow us to perform repetitive tasks • Variables record the values and state of elements of a program • Events trigger different elements of the program to be run at the correct time

More Related