Presentation is loading. Please wait.

Presentation is loading. Please wait.

And and or…and RANDOMNESS

Similar presentations


Presentation on theme: "And and or…and RANDOMNESS"— Presentation transcript:

1 And and or…and RANDOMNESS
Exploring Computer Science Lesson 4-10

2 Objectives The students will be able to:
Use conditionals with And and Or to write a grade program. Use a random number generator to write a dice program. Objectives

3 What’s the difference between AND and OR
What’s the difference between AND and OR? Give a GENERAL explanation of the difference. Give an example of each and explain how the meaning changes. Discussion

4 In an AND condition, both parts must be true for the statement to be true.

5 In an OR condition, the statement is true if either of the parts are true.

6 AND and OR Blocks in Scratch
AND and OR blocks are in Operators. Each side of the operation must be a conditional expression. AND and OR Blocks in Scratch

7 Let’s check out some code!
What do you think this code does? Let’s check out some code!

8 Crazy High School Grade Program
Your task is to make a Scratch program that will tell you a letter grade based on a percentage. Choose a sprite. Create a variable called ‘Grade’. Double click Grade to display the slider. When the green flag is clicked, the program should look at the value of Grade and the sprite should respond with a statement saying what letter grade corresponds to the slider value…as follows: A: greater than 89 B: greater than 79 and less than 90 C: greater than 69 and less than 80 D: greater than 59 and less than 70 F: less than 60 Extra Credit - At Crazy High School, students only qualify for tutoring if they have a B OR a D. After the sprite says the grade, make your program say, “You qualify for tutoring” if the grade is a B or D. You must use a single “if” block to decide if tutoring is needed. Crazy High School Grade Program

9 Now onto Randomness…

10 What does the word ‘random’ mean in English? Use it in a sentence.
What’s a ‘random number generator’? Check out this website: What’s Andrew’s answer to complaints that his generator isn’t ‘random’ enough? When might you want to generate one or more random numbers? Exemplify and explain. Opener

11 If I roll a pair of dice, will the numbers come out in order (2, then 3, then 4 the next roll, etc.)? Randomness

12 Randomness This unpredictability is called randomness.
Randomness can make games more exciting. For example, how many spaces will I get to move this turn? Randomness is also used in computer science for simulations and in scientific/statistical experiments. Randomness

13 Getting a Random Number in Scratch
pick random is under Operators. Getting a Random Number in Scratch

14 Let’s Look at a Program…
This is the start of a program… What do you think it does? Let’s Look at a Program…

15 Finish the Program… Download dice.sb from the website.
Finish the dice program so it works completely and then add a second die. You can duplicate the sprite but they need to work separately! See if you can figure out how to hide the variables from the screen. Finish the Program…


Download ppt "And and or…and RANDOMNESS"

Similar presentations


Ads by Google