Write algorithms with variables. Phil Bagge code-it

Similar documents
KS3 Questions Probability. Level 3 to 5.

Name. Is the game fair or not? Prove your answer with math. If the game is fair, play it 36 times and record the results.

Create Your Own World

What are the chances?

In this project, you will create a memory game where you have to memorise and repeat a sequence of random colours!

8.2 Union, Intersection, and Complement of Events; Odds

Name: Probability, Part 1 March 4, 2013

In this project you ll learn how to create a game, in which you have to match up coloured dots with the correct part of the controller.

Smyth County Public Schools 2017 Computer Science Competition Coding Problems

KS3 Levels 3-8. Unit 3 Probability. Homework Booklet. Complete this table indicating the homework you have been set and when it is due by.

Probability 1. Name: Total Marks: 1. An unbiased spinner is shown below.

Memory. Introduction. Scratch. In this project, you will create a memory game where you have to memorise and repeat a sequence of random colours!

Pong! The oldest commercially available game in history

Add in a new ghost sprite, and a suitable stage backdrop.

When a number cube is rolled once, the possible numbers that could show face up are

Pong Game. Intermediate. LPo v1

In this project you ll learn how to create a times table quiz, in which you have to get as many answers correct as you can in 30 seconds.

Consider the following compound statement: If Robert studies for the exam and gets a good night sleep, then Robert will do good on the exam.

Ada Lovelace Computing Level 3 Scratch Project ROAD RACER

Probability. Sometimes we know that an event cannot happen, for example, we cannot fly to the sun. We say the event is impossible

Assessment. Self Assessment. Teacher Assessment. Date Learning Objective(s) Achievement or. NC Level: Game Control Student Booklet P a g e 1

Lost in Space. Introduction. Scratch. You are going to learn how to program your own animation! Activity Checklist.

Before displaying an image, the game should wait for a random amount of time.

In this project you ll learn how to create a game in which you have to save the Earth from space monsters.

Summer Work th Grade Skills that are necessary for success in 7 th grade and beyond:

Clone Wars. Introduction. Scratch. In this project you ll learn how to create a game in which you have to save the Earth from space monsters.

Create Your Own World

Ghostbusters. Level. Introduction:

Targets for pupils in Year 6

CS 787: Advanced Algorithms Homework 1

Probability: introduction

LESSON ACTIVITY TOOLKIT 2.0

Whack-a-Witch. Level. Activity Checklist Follow these INSTRUCTIONS one by one. Test Your Project Click on the green flag to TEST your code

Starting from LEARNER NOTES edited version. An Introduction to Computing Science by Jeremy Scott

Create a Simple Game in Scratch

Assignment 5 due Monday, May 7

Pong! The oldest commercially available game in history

11+ Entrance Examination MATHEMATICS

Number Addition and subtraction

You are going to learn how to create a game in which a helicopter scores points by watering flowers in the city.

Mathematical challenges for able pupils. Year 1 A Counting, partitioning and calculating

Programming with Scratch

Let s start by making a pencil, that can be used to draw on the stage.

@Holyheadmaths GCSE METHODS REVISION- MARCH Higher Paper 1 (Non calculator)

Games for Drill and Practice

Lesson 2 Game Basics

Mock 2 Maths 2015 Answers

Probability Interactives from Spire Maths A Spire Maths Activity

Warm ups PLACE VALUE How many different ways can you make the number 365?

HW4: The Game of Pig Due date: Tuesday, Mar 15 th at 9pm. Late turn-in deadline is Thursday, Mar 17th at 9pm.

Brain Game. Introduction. Scratch

Park It XPLORE. LAY Allow your child time to freely explore the materials provided for this game. SK: SK: UILD LAY SK: What You Need: OBJECTIVE:

Rapid Recall Division

INTERACTING SPRITES MODULE 3: INVESTIGATION 1. Anima9ng Sprites

If event A is more likely than event B, then the probability of event A is higher than the probability of event B.

BOOM! subtract 15. add 3. multiply by 10% round to. nearest integer. START: multiply by 2. multiply by 4. subtract 35. divide by 2

Lesson 6.1 Linear Equation Review

Year 6. Mathematics A booklet for parents

Section Summary. Finite Probability Probabilities of Complements and Unions of Events Probabilistic Reasoning

1. A factory makes calculators. Over a long period, 2 % of them are found to be faulty. A random sample of 100 calculators is tested.

Probability & Statistics - Grade 5

3.6 Theoretical and Experimental Coin Tosses

Travelling Integers. Materials

Bellwork Write each fraction as a percent Evaluate P P C C 6

In this project we ll make our own version of the highly popular mobile game Flappy Bird. This project requires Scratch 2.0.

Relative Frequency GCSE MATHEMATICS. These questions have been taken or modified from previous AQA GCSE Mathematics Papers.

Math 1310: Intermediate Algebra Computer Enhanced and Self-Paced

HW4: The Game of Pig Due date: Thursday, Oct. 29 th at 9pm. Late turn-in deadline is Tuesday, Nov. 3 rd at 9pm.

saying the 5 times, 10 times or 2 times table Time your child doing various tasks, e.g.

Math Games Ideas. For School or Home Education. by Teresa Evans. Copyright 2005 Teresa Evans. All rights reserved.

Let s start by making a pencil that can be used to draw on the stage.

COMPOUND EVENTS. Judo Math Inc.

1. An office building contains 27 floors and has 37 offices on each floor. How many offices are in the building?

Maths is all around us and we re using it every day!

Project 1: Game of Bricks

The study of probability is concerned with the likelihood of events occurring. Many situations can be analyzed using a simplified model of probability

Convert the Egyptian numeral to Hindu-Arabic form. 1) A) 3067 B) 3670 C) 3607 D) 367

Probability. Probabilty Impossibe Unlikely Equally Likely Likely Certain

Maths Quiz. Make your own Mental Maths Game

Compound Probability. A to determine the likelihood of two events occurring at the. ***Events can be classified as independent or dependent events.

Introduction to Counting and Probability

A1 Problem Statement Unit Pricing

Exam III Review Problems

Chapter 3: PROBABILITY

Revision Topic 17: Probability Estimating probabilities: Relative frequency

CONCEPTS EXPLAINED CONCEPTS (IN ORDER)

Math 1313 Section 6.2 Definition of Probability

Probability Paradoxes

Fraction Race. Skills: Fractions to sixths (proper fractions) [Can be adapted for improper fractions]

Round Away. ten. Number created: 5,678 Round to the nearest ten

Unit 2: Accentuate the Negative

Module 4 Build a Game

This unit will help you work out probability and use experimental probability and frequency trees. Key points

TEKSING TOWARD STAAR MATHEMATICS GRADE 7. Projection Masters

Inspiring Creative Fun Ysbrydoledig Creadigol Hwyl. Kinect2Scratch Workbook

Section 6.1 #16. Question: What is the probability that a five-card poker hand contains a flush, that is, five cards of the same suit?

TEST A CHAPTER 11, PROBABILITY

Unit 7 Central Tendency and Probability

Building Successful Problem Solvers

Introduction to programming with Fable

Transcription:

Write algorithms with variables Phil Bagge code-it

Variables are like boxes Variables are like boxes. Information can be stored inside. You can look into the box to see what is inside. You can add things to a box. You can take things out of a box. You can label a box to show what is inside. Variables are different to boxes. Boxes can hold a mix of anything. Variables hold only one type of information, either numbers or strings. Numbers (whole number called integers) (decimal fractions or negative numbers called floats) Strings (numbers, letters and symbols integers Box label floats String Example

What do variables do? Variables are used by algorithms to store and adapt information. How do variables work? Variables can be set. This is like emptying the box and putting new information inside. Variables can be changed. This is where things are added to the box that change the content. Variables can be refered to by their name label. If score started at 6 set score to 0 would change score to 0 Change score by 1 would change score to 7. Change score by -2 would change score to 4.

Set and change variable example Variables can be set. This is like emptying the box and putting new information inside. Variables can be changed. This is where things are added to the box that change the content. If score started at 6 set score to 0 would change score to 0 If score started at 6 Change score by 1 would change score to 7 If score started at 6 Change score by -2 would change score to 4

We can write this algorithm like this set times to 6 change times by -4 repeat times wave change times by 3 repeat times bark

Lets look at the maths set times to 6 6 change times by -4 6-4=2 repeat times 2 wave change times by 3 2+3=5 repeat times 5 bark

We can write this algorithm like this set times to 4 say hum for times seconds change times by 3 repeat times wave

Lets look at the maths set times to 4 4 say hum for times seconds 4 change times by 3 4+2=6 repeat times 6 wave

Use these examples to help you write your own everyday algorithm that uses a variable set times to 6 change times by -4 repeat times wave change times by 3 repeat times bark set times to 4 say hum for times seconds change times by 3 repeat times wave You don t have to name your variable times

Algorithm Challenge Mel has programmed a game. Her sprite used the right arrow key to rurn right 10 degrees. She want to know how many times people use the right arrow in the game. Design an algorithm that uses a variable called ra to collect the information for her. Useful commands Set ra to 0 Change ra by 1 When green flag clicked Forever If right arrow pressed turn right 10 degrees

Algorithm Challenge Answers Mel has programmed a game. Her sprite used the right arrow key to rurn right 10 degrees. She want to know how many times people use the right arrow in the game. Design an algorithm that uses a variable called ra to collect the information for her. Useful commands Set ra to 0 Change ra by 1 When green flag clicked Set ra to 0 Forever If right arrow pressed turn right 10 degrees change ra by 1

Algorithm Challenge Bart has programmed a dice. His sprite used the space key to roll the dice. He want to know how many times people use the dice in the game. Design an algorithm that uses a variable called dice to collect the information for him. When green flag clicked Forever If space pressed say pick random 1 to 6

Algorithm Challenge Answers Bart has programmed a dice. His sprite used the space key to roll the dice. He want to know how many times people use the dice in the game. Design an algorithm that uses a variable called dice to collect the information for him. When green flag clicked Set dice to 0 Forever If space pressed say pick random 1 to 6 change dice by 1

Algorithm Challenge Carly has created a program to randomly choose odd or even. She has set it to run 100 times. She would like to know how many times even is choosen. Adapt her algorithm to use a variable called even to find that out. When green flag clicked Repeat 100 set random choice to pick random 1 to 6 if random choice = 1 say odd for 1 second Else say even for 1 second

Algorithm Challenge Answers Carly has created a program to randomly choose odd or even. She has set it to run 100 times. She would like to know how many times even is choosen. Adapt her algorithm to use a variable called even to find that out. When green flag clicked Set even to 0 Repeat 100 set random choice to pick random 1 to 6 if random choice = 1 say odd for 1 second Else say even for 1 second change even by 1

School Turnstile A school has installed a turnstile that every pupil has to enter through. Students can only use it to enter the school. Write an algorithm to record how many students are in the school. Commands you can use School opens Repeat until school closes Set variable counter to 0 Change variable counter by 1 If turnstyle arm moves 120

School Turnstile Turnstile arm A school has installed a turnstile that every pupil has to enter through. Students can only use it to enter the school. Write an algorithm to record how many students are in the school. School opens Set variable counter to 0 Repeat until school closes If turnstyle arm moves 120 Change variable counter by 1

Mel wants to know how many times people use the right arrow in her game. Design an algorithm that uses a variable called ra to collect the information for her. Useful commands Set ra to 0 Change ra by 1 When green flag clicked Forever If right arrow pressed turn right 10 degrees