Lesson 1: scratch basics

16
Introduction to Programming Scratch Lesson 1

description

 

Transcript of Lesson 1: scratch basics

Page 1: Lesson 1: scratch basics

Introduction to Programming

Scratch

Lesson 1

Page 2: Lesson 1: scratch basics

2

Goals

• What is an algorithm?• Scratch Interface• Variables• Conditional Statements • Turtle Graphics• Repetition

Page 3: Lesson 1: scratch basics

3

What is an algorithm?

• A step by step process (Algorithm)– Instructions for making tea (Pseudocode)

If no water in kettle: Put water in kettle

Turn on kettle

While water not boiling in kettle:Wait

Put water in cup …

Page 4: Lesson 1: scratch basics

4

Scratch user interface

Page 5: Lesson 1: scratch basics

5

Scratch stage

Page 6: Lesson 1: scratch basics

6

Stage + Sprite

• Exercise:– Point your mouse to coordinate x=0, y=0

• Exercise:– Get a new sprite on the screen

Page 7: Lesson 1: scratch basics

7

First scratch program

Page 8: Lesson 1: scratch basics

8

Variables

Exercise:Say a random number

Add a variable called “number”

Page 9: Lesson 1: scratch basics

9

Conditions

Exercise:– What does

this code do? – What are the

errors in the code?

Page 10: Lesson 1: scratch basics

10

Conditions

Exercise:– What does

this code do? – What are the

errors in the code?

– What if “number” is equal to 5?

Page 11: Lesson 1: scratch basics

11

Motion statements

• Move Right• Move Left• Big Steps• Small Steps• Move Up• Move Down • Exercise:

Double-click on the blocks to see what happens

Page 12: Lesson 1: scratch basics

12

More motion action

• Exercise– Make the sprite go to x=0, y=0

• Exercise– Make the sprite move 100 steps and turn 90 degrees

• Exercise– Make the sprite go in a square pattern

• Exercise– Make the sprite move when you hit a key

Page 13: Lesson 1: scratch basics

13

Pen statements

• Pen appears underneath sprite

• Pen must be set to “down” before it will draw

• Exercise: Draw a line after the sprite

Page 14: Lesson 1: scratch basics

14

Iteration

• Repeat statements• Exercise:

Guess what this code does

• Test your guess

Page 15: Lesson 1: scratch basics

15

Loop exercises

• Exercise: Draw this (10 diamonds)

• Exercise: Try to write your programs with as few statements as possible

Page 16: Lesson 1: scratch basics

16

More repeating exercises

• Exercise: Draw this in any colour

• Exercise: Change the colour of each square• Exercise: Draw a triangle, a pentagon a hexagon

and a circle.