PYTHON: BUILDING BLOCKS Sequencing & Selection

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

How SAS implements structured programming constructs
3.1.3 Program Flow control_1 Understand the need for structure Breaking things down.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 9 Decisions, Decisions, Decisions.
Programming in python Lesson 2.
Conditional Statements Introduction to Computing Science and Programming I.
Main task -write me a program
Chapter 3 Planning Your Solution
Do it now activity Correct the 8 syntax errors: Age = input(“How old are you?” If age = 10 Print(You are 10”) else: print(“You are not 10”)
Python Programming Using Variables and input. Objectives We’re learning to make use of if statements to enable code to ask questions. Outcomes Build an.
By the end of this session you should be able to...
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
PROGRAMMING In Lesson 2. STARTER ACTIVITY Complete the starter activity in your python folder – lesson 2 Now we will see how you got on and update your.
8. DECISION STRUCTURES Rocky K. C. Chang October 18, 2015 (Adapted from John Zelle’s slides)
3.1.3 Program Flow control Structured programming – SELECTION in greater detail.
Python Lesson 2.
Algorithms and Pseudocode
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Programming In Python. Starter Using the internet… Find what a programming language is.
GCSE COMPUTER SCIENCE Practical Programming using Python Lesson 4 - Selection.
PYTHON PROGRAMMING Year 9. Objective and Outcome Teaching Objective Today we will look at conditional statements in order to understand how programs can.
Introduction to Decision Structures and Boolean Variables
Programming – Algorithms (Flowcharts)
GCSE COMPUTER SCIENCE Practical Programming using Python
More on the Selection Structure
Making Choices with if Statements
Lesson 4 - Challenges.
Selection and Python Syntax
Lesson 1 An Introduction
Python: Control Structures
IGCSE 6 Cambridge Effectiveness of algorithms Computer Science
Teaching KS3 Computing Session 4 Theory: Boolean logic AND/OR/NOT
Microsoft Visual Basic 2005 BASICS
Learning to Program in Python
Learning to Program in Python
Learning to Program in Python
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
Story time Task 5 Computer Programming Gray , Calibri 24
Computational Thinking for KS3
DO NOW – Decompose a Problem
Selection Statements.
Algorithm and Ambiguity
Chapter 5: Control Structure
Introduction to Decision Structures and Boolean Variables
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Software Development Process
Global Challenge Walking for Water Lesson 2.
COMPUTATIONAL THINKING END OF UNIT ASSESSMENT
Computational Thinking
PYTHON: BUILDING BLOCKS Inputs & Outputs
Flowcharts and Pseudo Code
COMPUTATIONAL THINKING COMPUTATIONAL THINKING IN PROGRAMMING
Programming In Lesson 4.
Global Challenge Walking for Water Lesson 2.
Starter....
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Programming In.
Introduction to Python
WJEC GCSE Computer Science
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Starter Look at the hand-out.
Control Structures.
COMPUTING.
Presentation transcript:

PYTHON: BUILDING BLOCKS 8.2.4 - Sequencing & Selection Year 8 Computer Science - Midhurst Rother College

STARTER CHALLENGE Begin to think about how you might program a guess the number game. Think about the order of steps you would need to take. Think about variables, inputs and outputs. Think about what programming skills you may need to learn. This will be useful for later in the lesson!

LESSON OBJECTIVES Be able to explain the importance of sequencing and selection when writing code. Be able to implement these in Python.

BUILDING BLOCKS > Sequencing > Selection > Iteration An algorithm is a plan, a set of step-by-step instructions to solve a problem. There are three basic building blocks to use when designing algorithms. > Sequencing > Selection > Iteration This lesson we are going to focus on sequencing and selection.

SEQUENCING Algorithms consist of instructions that are carried out one after another. Sequencing is the specific order in which instructions are performed in an algorithm. It is crucial that the steps in an algorithm are performed in the right order - otherwise the algorithm will not work correctly. CLASS DISCUSS: What are the process involved in brushing your teeth? Why would sequencing be important?

SEQUENCING IN PYTHON In Python, we sequence from top to bottom. This code would not work due to errors in its sequencing. What are these errors? How could we write this code correctly?

SEQUENCING IN PYTHON We must make sure a variable has a value before we can use it. We must make sure our variables are ready before we print them.

SELECTION Selection is a decision or question. At some point in an algorithm there may need to be a question because the algorithm has reached a step where one or more options are available. Depending on the answer given, the algorithm will follow certain steps and ignore others. Without selection, different paths would not be included in algorithms. This means that the solutions created would not be realistic. CLASS DISCUSS: Have we used selection already?

We use an ‘If Else’ Statement in Python. SELECTION IN PYTHON We use an ‘If Else’ Statement in Python.

We use an ‘elif’ in Python if we need more than two outcomes. SELECTION IN PYTHON We use an ‘elif’ in Python if we need more than two outcomes.

COMPARISON OPERATORS Comparison operators are used to compare two values. An expression using a comparison operator evaluates to be True or False. How could you use this in creating a program?

YOUR TASK Start the tasks in the 8.2.4 sequence & selection task sheet found on rother-net.co.uk. Work your way through the tasks. Remember in your workbook to: Read the work carefully. Open any other tasks needed. At the end of a lesson in the box for this topic add a screenshot of the most complex task you got working. Update your keyword table.

TASK DISCUSS: Did you complete the tasks? Did you have any issues? Could you program a guess the number game? How did you do it?

YOUR EVIDENCE Remember in your workbook to: In the box for this topic add a screenshot of the most complex task you got working. Write a short paragraph of what you learnt this lesson. Did you face any challenges? How did you overcome them? Did you face any errors (e.g. syntax)? How did you find and correct them? Update your keyword table.

THINGS TO REMEMBER From the unit so far, you need to remember what the following mean: Algorithm Variable Function Input / Output Data Types Casting Sequencing Selection Can you remember?

PLENARY Work Showcase Q & A Choose a student’s program. Allow other students to ask questions about the code. Discuss how programs could be improved. PLENARY Work Showcase Q & A