PYTHON PROGRAMMING Year 9. Objective and Outcome Teaching Objective Today we will look at conditional statements in order to understand how programs can.

Slides:



Advertisements
Similar presentations
Selection Statements Make a decision based on conditions Allows the computer to be intelligent.
Advertisements

Main task -write me a program
Python.
Algorithms In general algorithms is a name given to a defined set of steps used to complete a task. For example to make a cup of tea you would fill the.
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.
Python Programming Introduction to programming using python.
Python – Making Decisions Lecture 02. Control Structures A program that only has one flow is useful but limited. We can use if statements to make these.
Bug Session Four. Session description Objectives Session activities summary Resources Prior knowledge of sequencing instructions using Bug Bug website.
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.
Coding Design Tools Rachel Gauci. What are Coding Design Tools? IPO charts (Input Process Output) Input- Make a list of what data is required (this generally.
Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 7 Conditionals and Loops 4/18/09 Python Mini-Course: Day 2 - Lesson 7.
1. Understand the application of Pseudo Code for programming purposes 2. Be able to write algorithms in Pseudo Code.
MIT App Inventor Lesson 4 – Decision Making. Agenda Comparisons ◦ Relational Operators Conditions (state checking) ◦ Boolean Operators.
More Python!. Lists, Variables with more than one value Variables can point to more than one value at a time. The simplest way to do this is with a List.
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
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.
Algorithms and Pseudocode
LO: We’re learning to outline a program using Pseudo Code.
COMPUTER PROGRAMMING Year 9 – lesson 1. Objective and Outcome Teaching Objective We are going to look at how to construct a computer program. We will.
Algorithms and Flowcharts
Introduction to Python Selection Non-Linear Programs.
GCSE COMPUTER SCIENCE Practical Programming using Python Lesson 4 - Selection.
DEVRY CIS 170 C I L AB 2 OF 7 D ECISIONS Check this A+ tutorial guideline at decisions For.
Starter What does the following code do?
Introduction to Decision Structures and Boolean Variables
GCSE COMPUTER SCIENCE Practical Programming using Python
Writing algorithms Introduction to Python.
Input and Output Upsorn Praphamontripong CS 1110
Introducing Instructions
Selection: Non-linear programs
Line Continuation, Output Formatting, and Decision Structures
Lesson 4 - Challenges.
IF statements.
If, else, elif.
Understand the Programming Process
Learning to Program in Python
Learning to Program in Python
Line Continuation, Output Formatting, and Decision Structures
Learning to Program in Python
Learning to Program in Python
Learning to Program in Python
Introduction to pseudocode
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Lesson 1: Fundamentals of Programming
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.
Selection (IF Statements)
Story time Task 5 Computer Programming Gray , Calibri 24
Coding Concepts (Basics)
Introduction to Programming
Introduction to Algorithms and Programming
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
3. Decision Structures Rocky K. C. Chang 19 September 2018
Understand the Programming Process
Selection Statements.
Chapter 5: Control Structure
PYTHON: BUILDING BLOCKS Sequencing & Selection
Module 3 Selection Structures 4/4/2019 CSE 1321 Module 3.
Flowcharts and Pseudo Code
An Introduction to Linux
Life is Full of Alternatives
Programming In Lesson 4.
CHAPTER 5: Control Flow Tools (if statement)
Introduction to Python
Introduction to Programming
WJEC GCSE Computer Science
Hardware is… Software is…
WRITING AN ALGORITHM, PSEUDOCODE, AND FLOWCHART LESSON 2.
Presentation transcript:

PYTHON PROGRAMMING Year 9

Objective and Outcome Teaching Objective Today we will look at conditional statements in order to understand how programs can become more intelligent Learning Outcome All – of you will have written a simple IF statement and executed a program with a condition Most – of you will be able to use comparative operators in an IF statement Some – of you will be able to run IF, elif programs

Today’s lesson Computer programmers can make programs that are so intelligent they can make decisions which can have a direct bearing on our lives Critical systems such as planes on computers must react to conditions OR simple programs like a login for a computer IF Elif Else

PseudoCode The syntax of a simple IF statement IF a < b Do something IF a > b Do something This is how a program would be written in PSEUDO code Pseudo code is the program written in a form close to English It will not run as it needs the correct syntax

A simple IF program If a is greater than b (>) If a is less than b (<)

A simple IF program This is the output to the program

The syntax explained Input the two variables Note the colon Print if a is the biggest Print if a is the smallest

Exercise 1 (5 minutes) Write a program that asks for two user’s names and ages and then returns a message to say which one is older Instructions (Algorithm) IF userage1 > userage2 PRINT “Message……” IF userage1 < userage2 PRINT “Message…….”

Extend the program The program we have just written does not work if they are the same age. We need to add another IF statement to overcome this Remember (==) is the sign for equal to Algorithm IF userage1 > userage2 PRINT “Message……” IF userage1 < userage2 PRINT “Message…….” IF userage1 == userage2 – PRINT “Message ……”

Check Point What we have done: We’ve created a program which is non – linear It is selective and will behave differently with input We have used an IF statement We have used three operators – (>) greater than – (<) less than – (==) equal to

Program: temperature.py Write a program that takes in the temperature from the user in Fahrenheit PSEUDO CODE IF temperature is greater than 90 – PRINT (“It is hot outside”) ELSE PRINT (“It is cold outside”) PRINT (“Program done”)

Program: Teenager Write a program that uses an IF statement. It does the following: Takes in the user’s name Takes in the user’s age If they are LESS than 13 they are still a child If they are 13 or greater(>=) they are a teenager

Check Point Now we have extended our program so that we have an IF Else statement This gives us much more control over our program In a way our programs are starting to behave more intelligently

Plenary Today we have looked at the power of an IF statement IF is a small word which is very powerful Can we think of examples of how it might be used? We have also looked at comparative operators such as ==