Nate Brunelle Today: Conditional Decision Statements

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.
Logical Operators and While Loops CS303E: Elements of Computers and Programming.
Selection Victor Norman CS104 Calvin College. Reading Quiz Counts toward your grade.
Discussion1 Quiz. Q1 Which of the following are invalid Java identifiers (variable names)? a) if b) n4m3 c) Java d) e) DEFAULT_VALUE f) bad-choice.
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
1 9/24/07CS150 Introduction to Computer Science 1 Relational Operators and the If Statement.
1 CS150 Introduction to Computer Science 1 Relational Operators and the If Statement 9/22/08.
The If/Else Statement, Boolean Flags, and Menus Page 180
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.
CS140: Intro to CS An Overview of Programming in C by Erin Chambers.
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.
Python Lab: Control Statements Conditionals, Loops, Iterations Proteomics Informatics, Spring 2014 Week 4 18 th Feb, 2014
Walk through previous lecture. TSP Questions: How many tours are there? How do you solve it? How fast can you solve it?
Branching and Conditions CSIS 1595: Fundamentals of Programming and Problem Solving 1.
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.
CS31: Introduction to Computer Science I Discussion 1A 4/9/2010 Sungwon Yang
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
CONDITIONALS. Boolean values Boolean value is either true or false It is name after the British mathemetician, George Boole who first formulated Boolean.
Decisions in Python Boolean functions. A Boolean function This is a function which returns a bool result (True or False). The function can certainly work.
Logical Operators, Boolean Variables, Random Numbers This template was just too good to let go in one day!
Variables, Types, Expressions Intro2CS – week 1b 1.
A: A: double “4” A: “34” 4.
Decision Making CMSC 201 Chang (rev ).
Lesson thirteen Conditional Statement "if- else" ©
The If Statement There are no switch statements in Python. You need to use just if statements. There are no switch statements in Python. You need to use.
Student Q and As from 5.1 – 5.7, 5.11 Students of CS104, Fall 2013 (and me)
A Introduction to Computing II Lecture 1: Java Review Fall Session 2000.
Python Basics  Values, Types, Variables, Expressions  Assignments  I/O  Control Structures.
CS 139 – Programming Fundamentals Lecture 08A. Relational/comparison Operators Relational Operator Meaning > is greater than < is less than >= is greater.
C syntax (simplified) BNF. Program ::= [ ] Directives ::= [ ] ::= | |… ::=#include > ::=#define.
CPSC 233 Tutorial January 21 st /22 nd, Linux Commands.
Indentations makes the scope/block Function definition def print_message (): print “hello” Function usages print_message () hubo.move ()// hubo is a class.
G. Pullaiah College of Engineering and Technology
Introduction to Python
Decisions Chapter 4.
Basic operators - strings
String operations; More on function definitions; Conditional execution
CS 200 Branches Jim Williams, PhD.
Review Operation Bingo
Imperative Programming
And now for something completely different . . .
Console input.
Types, Truth, and Expressions (Part 2)
Selection CSCE 121 J. Michael Moore.
Nate Brunelle Today: Repetition, A Trip To The Moon
Types, Truth, and Expressions (Part 2)
Nate Brunelle Today: Repetition, Repetition
Types, Truth, and Expressions (Part 2)
Types, Truth, and Expressions (Part 2)
Nate Brunelle Today: Functions again, Scope
Program Flow Control Selection & repetition
Flow Control Statements
If Statements.
Nate Brunelle Today: Values and Types
Nate Brunelle Today: Conditional Decision Statements
Types, Truth, and Expressions (Part 2)
Nate Brunelle Today: Functions
Nate Brunelle Today: Strings, Type Casting
Nate Brunelle Today: Values and Types
Understanding Conditions
ECS15 boolean.
Types, Truth, and Expressions
CSE 231 Lab 2.
Nate Brunelle Today: Conditional Decision Statements
Nate Brunelle Today: Functions
Nate Brunelle Today: Strings, Type Casting
Nate Brunelle Today: Functions again, Scope
CSCE 206 Lab Structured Programming in C
Imperative Programming
Presentation transcript:

Nate Brunelle Today: Conditional Decision Statements CS1110 Nate Brunelle Today: Conditional Decision Statements

Questions?

Last Time Functions Default Arguments

Expression vs. Statement Expression: simplifies to a value 2 2+3 Amount_to_be_fancy(3**2) Statement: Does something x=3 print(‘Hello World!’)

Conditional decision Statement if boolean expression: action elif boolean expression: else:

Conditional decision Statement if boolean expression: action elif: another action else: yet another action 0 or more 0 or 1

Values and Types (not exhaustive) Operators -50 ,0 ,5, 30, 512 int 3+7, 3*7, 3-7, 3/7 0.5, 1.2, 0.333333 float +, *, -, /, //, %, **, compare ‘hi’, “hi”, ‘hello world! ✃’ str +, * int Print, input function print() True, False bool and, or, not

and, or, not examples x<2 and x>0 x<0 or x>2 not x>2 When all things are true x<0 or x>2 When any of the things are true not x>2 When the thing is false

and, or, not and or not True if all things are True False if any things are False or True if any things are True False if all things are False not True if the thing was False False if the thing was True