Computing Flowcharts and Pseudocode Lesson 2 Jenny Hughes

  • Slides: 21
Download presentation
Computing: Flowcharts and Pseudocode Lesson 2 Jenny Hughes

Computing: Flowcharts and Pseudocode Lesson 2 Jenny Hughes

Learning Objective • To design, use and evaluate computational abstractions that model the state

Learning Objective • To design, use and evaluate computational abstractions that model the state and behaviour of real-world problems and physical systems. Success Criteria • To know how computers make decisions. • To use selection in flowcharts. • To understand how pseudocode is used to describe algorithms.

Hungry Hedgehog Flo the hedgehog is very hungry! Using your knowledge of flowcharts, put

Hungry Hedgehog Flo the hedgehog is very hungry! Using your knowledge of flowcharts, put these instructions into the right order to help her make her recipe for Slimy Snail Soup. Give everything a good stir. Stir well, serve and enjoy! Add a splash of slippery slug juice. Put slimy snails into pot. Boil for 15 minutes. Find slimy snails in garden. Add a dash of wriggly worm. Start Get a large cooking pot. Stop

Hungry Hedgehog Here’s the answer. You might have put some of the instructions into

Hungry Hedgehog Here’s the answer. You might have put some of the instructions into a slightly different order to this (e. g. add a sprig of slippery slug juice before the dash of wriggly worm). Give everything a good stir. That’s okay. Stir well, serve and enjoy! However, some instructions must be in the right order. Which ones do you think Put slimy snails into pot. these are? Find slimy. Yay, snails in garden. thanks guys, I was starving! Start Add a splash of slippery slug juice. Boil for 15 minutes. Add a dash of wriggly worm. Get a large cooking pot. Stop

Selection How do computers make decisions? Computers make decisions in a similar way to

Selection How do computers make decisions? Computers make decisions in a similar way to humans. And hedgehogs. Let’s see how this works: Next Slide

Selection Imagine that Flo wakes up one day and looks up at the sky.

Selection Imagine that Flo wakes up one day and looks up at the sky. Her thought-process goes something like this… What is the weather like today? Is it sunny? If the answer is YES, then Flo will put on her sunglasses. (What, haven’t you seen a hedgehog with sunglasses before? ) If the answer is NO, then Flo will put on her woolly hat. Next Slide

Selection We can write this in a more precise way: IF it is sunny,

Selection We can write this in a more precise way: IF it is sunny, THEN Flo will put on her sunglasses ELSE Flo will on her woolly hat. END IF This method of writing the steps of a process is called pseudocode (soo – dough – code). Notice these words in CAPITALS – they are special pseudocode words. Key Term Pseudocode is a simple but structured way of writing algorithms. It is not a real programming language. Programmers often use pseudocode when they are designing computer programs.

Selection We can also show Flo’s thinking by using a new flowchart symbol. This

Selection We can also show Flo’s thinking by using a new flowchart symbol. This flowchart symbol is called a decision box. Notice how it has one input (the top flowline), and two outputs. The outputs are either YES and NO. Is it sunny today? Yes No Next Slide

Selection Let’s put our flowchart and pseudocode side-by-side: IF it is sunny, THEN Flo

Selection Let’s put our flowchart and pseudocode side-by-side: IF it is sunny, THEN Flo will put on her sunglasses Is it sunny today? Yes Flo will put on her sunglasses. No Flo will put on her woolly hat. ELSE Flo will on her woolly hat. END IF Which do you prefer – the flowchart or the pseudocode?

Selection “Is it sunny today? ” This question is called a condition. There are

Selection “Is it sunny today? ” This question is called a condition. There are two possible outcomes: YES or NO Is it sunny today? No “Is it sunny today? ” This question is called a condition. There are two possible outcomes: YES or NO IF it is sunny, THEN Flo will put on her sunglasses Yes Key Terms Selection is when computers make decisions. A computer can be programmed to make a selection between two or more choices, depending on the condition (the question).

Flowchart and Pseudocode Challenges Let’s put your knowledge into action. You are female, super

Flowchart and Pseudocode Challenges Let’s put your knowledge into action. You are female, super strong and you can Answer: Wonder Woman! fly. According to this flowchart, which superhero are you? Start Yes No Can you fly? Do you have super strength? No You’re not a Superhero Stop Yes Do you have super strength? Are you female? Yes No You are Spiderman You are She-Hulk Stop No You are Falcon Stop Yes Are you female? Yes No You are Superman You are Wonder Woman Stop

Flowchart and Pseudocode Challenges Let’s try that again. You are female, super strong but

Flowchart and Pseudocode Challenges Let’s try that again. You are female, super strong but you can’t fly. Answer: She-Hulk! According to this flowchart, whichsuperhero are you? Start Yes No Can you fly? Do you have super strength? No You’re not a Superhero Stop Yes Do you have super strength? Are you female? Yes No You are Spiderman You are She-Hulk Stop No You are Falcon Stop Yes Are you female? Yes No You are Superman You are Wonder Woman Stop

Network Login Most computer systems require thatusers enter a username and a password. What

Network Login Most computer systems require thatusers enter a username and a password. What happens if a wrong username is entered? What happens if a wrong password is entered? What happens if both username and password are wrong? What happens if both username and password are correct? Using your knowledge of flowcharts and pseudocode, in pairs: 1. Draw a flowchart which could describe a computer login process. 2. Write pseudocode which describes this same process.

Network Login Need help getting started? Start ENTER Username ENTER Password IF Username and

Network Login Need help getting started? Start ENTER Username ENTER Password IF Username and Password are correct THEN Enter Username Enter Password …what comes next? Is Username correct? Yes … what comes next … ? No

Network Login Start Your answers might look like this: Enter Username Enter Password Is

Network Login Start Your answers might look like this: Enter Username Enter Password Is Username correct? No Error Messag e Stop Yes Is Password correct? Yes Login to Network Stop ENTER Username ENTER Password IF Username and Password are correct THEN Login to Network ELSE Error Message END IF

Personality Test Algorithm • What kind of person are you? • Look at one

Personality Test Algorithm • What kind of person are you? • Look at one of these online personality test quizzes. à https: //www. 16 personalities. com/free-personality-test à http: //www. kidzworld. com/quizzes/by-section/me à Can you find any others? • These are only intended to be fun. Always take care when searching on the Internet. If in doubt about anything you see online, always check first with an adult whom you trust, such as a parent or teacher.

Personality Test Algorithm • Using your knowledge of flowcharts and selection, your final challenge

Personality Test Algorithm • Using your knowledge of flowcharts and selection, your final challenge is to create a Personality Test Algorithm. • You should start by drawing a flowchart. • Your flowchart should contain a series of questions (such as “are you a loud person? ”). Note: questions should have YES or NO answers. • At the bottom of your flowchart you will find out your personality type! • Further challenge for Superstars: Can you write your algorithm as pseudocode? Are you a loud person? Yes No

Personality Test Algorithm Start Are you a loud person? No Do you like sports?

Personality Test Algorithm Start Are you a loud person? No Do you like sports? Yes Do you get upset easily? No This might get a bit complicated! No Are you a thoughtful person? Yes What is my personality? No

Personality Test Algorithm Key Terms Pseudocode is a simple but structured way of writing

Personality Test Algorithm Key Terms Pseudocode is a simple but structured way of writing algorithms. Key Terms Selection is when computers make decisions. A computer can be programmed to make a selection betweentwo or more choices, depending on the condition (the question). Pause for Thought Computers can be programmed to make decisions. Computers can often work much faster than humans can. Do you think that computers will therefore one day replace humans and take over all of our jobs? Why / why not?

Rate Your Progress Green light: you feel fully confident with this objective and you

Rate Your Progress Green light: you feel fully confident with this objective and you understand it well. Amber light: you have understood most of the objective and you are happy with your progress. Red light: you have understood some of the objective and you will think about it some more later on, perhaps asking a friend or teacher for help. Success Criteria • To know how computers make decisions. • To use selection in flowcharts. • To understand how pseudocode is used to describe algorithms.

Nailing It Down • We have learned a lot today about selection and pseudocode.

Nailing It Down • We have learned a lot today about selection and pseudocode. • Next lesson we’ll learn how computers store information and do things again and again. • Did you know that you can use your computer to draw flowcharts? • Try out this free website to draw flowcharts online: https: //www. draw. io/ • With most word processors such as Microsoft Word, you can insert flowchart shapes. • See if you can improve your flowcharts by drawing them on a computer.