Computer Science 1000 LOGO II. Boolean Expressions like Excel and Scratch, LOGO supports three Boolean operators less than (<) equal (=) greater than.

Slides:



Advertisements
Similar presentations
Lesson 6: Boolean and If Statements Computer Science 1 Mr. Bernstein.
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.
CS0007: Introduction to Computer Programming
Computer Science 1000 LOGO I. LOGO a computer programming language, typically used for education an old language (1967) the basics are simple: move a.
If Statements & Relational Operators Programming.
Compunet Corporation1 Programming with Visual Basic.NET Selection Structure If-Else Week 4 Tariq Ibn Aziz.
5-1 Flow of Control Recitation-01/25/2008  CS 180  Department of Computer Science  Purdue University.
Selection Statements choice of one among several blocks of code Java supports 3 kinds of selection statements: if statement – selects one block or leaves.
Conditions What if?. Flow of Control The order of statement execution is called the flow of control Unless specified otherwise, the order of statement.
School of Computing Science CMT1000 Ed Currie © Middlesex University 1 CMT1000: Introduction to Programming Ed Currie Lecture 5B: Branch Statements - Making.
C++ for Engineers and Scientists Third Edition
Running JavaScript Chapter 18.
1 Python Chapter 4 Branching statements and loops © Samuel Marateck 2010.
INTRODUCTION TO PYTHON PART 3 - LOOPS AND CONDITIONAL LOGIC CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD.
Q and A for Section 4.4 CS 106, Fall Q1 Q: The syntax for an if statement (or conditional statement) is: if _______________ : _____________ A: if.
Java Programming Constructs 1 MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation.
Branching and Conditions CSIS 1595: Fundamentals of Programming and Problem Solving 1.
CHAPTER 4: CONDITIONAL STRUCTURES Introduction to Computer Science Using Ruby (c) 2012 Ophir Frieder et al.
Programming Fundamentals. Today’s lecture Decisions If else …… Switch Conditional Operators Logical Operators.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 7 Decision Making : selection statements.
1 4.8The do/while Repetition Structure The do/while repetition structure –Similar to the while structure –Condition for repetition tested after the body.
Lesson 5: Working with Formulas and Functions Logical and 3D Formulas.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 21, 2005 Lecture Number: 10.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
 Learn about control structures  Examine relational and logical operators  Explore how to form and evaluate logical (Boolean) expressions  Learn how.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
Chapter 7 Selection Dept of Computer Engineering Khon Kaen University.
Conditional Expression One of the most useful tools for processing information in an event procedure is a conditional expression. A conditional expression.
Advanced Computer Science Lesson 4: Reviewing Loops and Arrays Reading User Input.
Counter-Controlled Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Copyright © 2012 Pearson Education, Inc. Chapter 4: Making Decisions.
Algorithms Writing instructions in the order they should execute.
CSE 1341 Honors Note Set 05 Professor Mark Fontenot Southern Methodist University.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Decision Structures and Boolean Variables. Sequence Structures Thus far, we’ve been programming “sequence structures” Thus far, we’ve been programming.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 4 Control Structures I: Selection.
Chapter 4 Control Structures I. Chapter Objectives Learn about control structures Examine relational and logical operators Explore how to form and evaluate.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
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.
Basic Conditions. Challenge: ● Ask the user his/her name ● If it’s “Wally,” jeer him ● Pause video and try on your own.
Controlling Computers with Programs When you create a computer program you are creating a set of instructions that tell the computer exactly and completely.
Lesson thirteen Conditional Statement "if- else" ©
Computer Science 1000 Algorithms III. Multiple Inputs suppose I ask you to write a program that computes the area of a rectangle area = length * width.
USING CONDITIONAL CODE AMIR KHANZADA. Conditional Statement  Conditional statements are the set of commands used to perform different actions based on.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Python Arithmetic Operators OperatorOperationDescription +AdditionAdd values on either side of the operator -SubtractionSubtract right hand operand from.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Functions with Arguments and Return Values, Oh My! CS303E: Elements of Computers and Programming.
Silberschatz and Galvin  C Programming Language Decision making in C Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University.
 Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do.
CS0007: Introduction to Computer Programming
Making Choices with if Statements
Printing Lines of Asterisks
If, else, elif.
Microsoft Visual Basic 2005 BASICS
CSC115 Introduction to Computer Programming
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Chapter (3) - Looping Questions.
Conditions and Boolean Expressions
CS139 October 11, 2004.
Selection Statements.
Computer Science Core Concepts
An Introduction to Linux
Understanding Conditions
CS2011 Introduction to Programming I Selections (I)
Relational Operators.
Relational Expressions
CHAPTER 5: Control Flow Tools (if statement)
If-Statements and If/Else Statements
4a- If And Else Lingma Acheson CSCI N331 VB .NET Programming
Presentation transcript:

Computer Science 1000 LOGO II

Boolean Expressions like Excel and Scratch, LOGO supports three Boolean operators less than (<) equal (=) greater than (>) unlike Excel and Scratch, the input to must be numbers = can be used to compare strings

Boolean Expressions - Uses Boolean expressions are rarely used on their own instead, they are used as input to other expressions a common example: conditional statements a programming construct that allows execution of a particular set of statements only under certain conditions

If Statement the simplest conditional two parts a Boolean expression a set of statements in brackets syntax: if booleanEx [ statements ] These execute if this is true

If Statements and Procedures by placing an if statement in a procedure, we can conditionally execute code based on user input example: write a function called forwardOnly, that takes a single number as input, and moves the turtle forward by that amount, but only if that amount is positive. Otherwise, the turtle should not move.

IfElse an if statement allows us to specify what happens when an expression is true an ifelse statement allows us to also specify what happens when the statement is false syntax: ifelse booleanEx [true statements] [false statements] These execute if this is true, otherwise these execute

Example: rewrite our function called forwardOnly, that takes a single number, and moves the turtle forward by that amount, but only if that amount is positive. Otherwise, the program should print Error

Multiple Inputs procedures allow multiple inputs from users when creating the procedure give each input a unique variable name when calling the procedure specify one value for each input note that they are applied in order

Example: rewrite the dashedLine example so that it takes two parameters. The first parameter determines how many dashes are drawn. The second parameter determines how long the dashes are.