Control Structures If Else Statement. S E S Q C E N U …consecutive steps (or groups of steps) processed one after another in the order that they arise.

Slides:



Advertisements
Similar presentations
Selection Feature of C: Decision making statements: It allow us to take decisions as to which code is to be executed next. Since these statements control.
Advertisements

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.
CSE 1301 Lecture 5B Conditionals & Boolean Expressions Figures from Lewis, “C# Software Solutions”, Addison Wesley Briana B. Morrison.
Making Decisions in Python Sec 9-10 Web Design. Objectives The student will: Understand how to make a decision in Python Understand the structure of an.
Subject: Information Technology Grade: 10
Do Loops A Do..Loop terminates based on a condition that is specified Execution of a Do..Loop continues while a condition is True or until a condition.
1 CS 105 Lecture 4 Selection Statements Wed, Jan 26, 2011, 6:05 pm.
Single selection syntax if ( expression ) { statements; } TRUE FALSE expression if clause 1. Statemens are executed when expression is true 2. { } can.
1 Arithmetic in C. 2 Type Casting: STOPPED You can change the data type of the variable in an expression by: (data_Type) Variable_Name Ex: int a = 15;
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to Python Programming Outline 2.1 Introduction 2.2 First Program in Python: Printing.
CIS101 Introduction to Computing Week 12 Spring 2004.
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”)
INTRODUCTION TO PYTHON PART 3 - LOOPS AND CONDITIONAL LOGIC CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD.
Chapter 9 IF Statement Bernard Chen. If Statement The main statement used for selecting from alternative actions based on test results It’s the primary.
Python – Part 4 Conditionals and Recursion. Modulus Operator Yields the remainder when first operand is divided by the second. >>>remainder=7%3 >>>print.
Programming.
Control Structures FOR Statement Looping.
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 – 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.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
1. We’ve learned that our programs are read by the compiler in order, from top to bottom, just as they are written The order of statement execution is.
Flow of Control Part 1: Selection
1 Boolean Expressions to Make Comparisons Boolean expression –Represents only one of two states –Expression evaluates to either true or false Expressions.
MULTIPLE ALTERNATIVES IF… THEN… ELSEIF SELECT CASE.
Python Programming Using Variables and input. Objectives We’re learning to use basic knowledge of variables combined with user input. Outcomes Continue.
Chapter 3: Branching and Program Flow CSCI-UA 0002 – Introduction to Computer Programming Mr. Joel Kemp.
Validation "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to.
Python - Selection Selection means selecting (or choosing) what to do next. Should I cycle to school, or ask for a lift? If it’s a sunny day I might cycle.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Basic Conditions. Challenge: ● Ask the user his/her name ● If it’s “Wally,” jeer him ● Pause video and try on your own.
Topics: Selection Statements. Processing Involving Selecting Instructions An instruction that allows deviation and selection to take place uses the ‘IF’
Decision Making CMSC 201 Chang (rev ).
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 3 Decision Trees Conditionals.
3.1.3 Program Flow control Structured programming – SELECTION in greater detail.
These Guys? Wait, What? Really?  Branching is a fundamental part of programming  It means taking an action based on decision  The decision is dependent.
Learning Objective To be able to… Understand flow chart symbols Complete and correct flow chart algorithms Create a program based on a flow chart.
CSE202: Lecture 5The Ohio State University1 Selection Structures.
Control Structures WHILE Statement Looping. S E Q C E N U E REPITITION …a step or sequence of steps that are repeated until some condition is satisfied.
Python – Part 4 Conditionals and Recursion. Conditional execution If statement if x>0:# CONDITION print (‘x is positive’) Same structure as function definition.
PYTHON IF-STATEMENTS. What you know If something is true, then something happens Example If you heat water to 100 degrees Celsius, then it boils If it.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Week 4 Computer Programming Gray , Calibri 24
Selection Control Structure
Selection: Non-linear programs
Sequence, Selection, Iteration The IF Statement
Scratch – Simple Programming
Selection and Python Syntax
Printing Lines of Asterisks
If, else, elif.
پروتكل آموزش سلامت به مددجو
Week 4 Computer Programming Year 9 – Unit 9.04
Visual Basic – Decision Statements
Selection Statements.
Comparing Strings Strings can be compared using the == and != operators String comparisons are case sensitive Strings can be compared using >, =, and.
Chapter 5: Control Structure
If Statements.
Adding Intelligence Check for the presence or absence of a condition in the environment Take the appropriate actions Involves making a choice (to do or.
Topics The if Statement The if-else Statement Comparing Strings
SELECTIONS STATEMENTS
Learning Intention I will learn about programming using selection (making choices) with one condition.
Chapter 3: Selection Structures: Making Decisions
Boolean Expressions to Make Comparisons
Programming Concepts and Database
Chapter 4: Boolean Expressions, Making Decisions, and Disk Input and Output Prof. Salim Arfaoui.
There many situations comes in real life when we need to make some decisions and based on these decisions, we decide what should we do next. Similar situations.
Chapter 3: Selection Structures: Making Decisions
General Computer Science for Engineers CISC 106 Lecture 03
Presentation transcript:

Control Structures If Else Statement

S E S Q C E N U …consecutive steps (or groups of steps) processed one after another in the order that they arise. E A bit like reading through a cooking recipe, one line at a time.

Sometimes we want to test if one condition is true or false. For example, IF Sarah > 16, then she can learn to drive ELSE she is too young to drive

Condition? YesNo …a decision-making step. True Block False Block

In PYTHON, what is the SYNTAX for the IF statement? if : else : Name='Sydney' if len(Name)>15: print('You have a long name!') else: print('You have a short name!') An example of PYTHON IF Statement Syntax

Task 1 1)Create a program that prompts the user for their age 2)If their age is less than 14 it should produce a simple funny statement 3) If their age is greater than or equal to 14, it should produce a different statement 4) Create your program in SCRIPT mode and save it as Simple If Statement

Task 2 1)Create a program that prompts the user for their NAME and the YEAR they were born. 1)If their year is after 1999, the program should output ‘ Welcome NAME, you are a 21 st Century Child!’ 3) If their year is not after 1999, the program should output ‘ Welcome NAME, you are a 20 th Century child! ’ 4) Create your program in SCRIPT mode and save it as Simple If Statement 2

Task 3 1)Create a program that prompts the user for a PASSWORD 2)If the entered password is less than 8 characters long, it should output ‘ Password Rejected.’ 3) If the entered password is at least 8 characters long, it should output ‘ Password Accepted.’ 4) Create your program in SCRIPT mode and save it as Simple If Statement 3