Conditional Execution
Conditional Execution
Chapter 3
Python for Informatics: Exploring Information
x = 5 Yes
X < 10 ?
No print 'Smaller'
Yes
X > 20 ?
No
print 'Bigger'
Conditional Steps
Program:
x = 5 if x < 10:
print 'Smaller'
if x > 20: print 'Bigger'
Output:
Smaller Finis
print 'Finis'
print 'Finis'
Comparison Operators
? Boolean expressions ask a question and produce a Yes or No result which we use to control program flow
? Boolean expressions using comparison operators evaluate to - True / False - Yes / No
? Comparison operators look at variables but do not change the variables
Python
< = > !=
Meaning
Less than Less than or Equal
Equal to Greater than or Equal
Greater than Not equal
Remember: "=" is used for assignment.
Comparison Operators
x = 5 if x == 5 :
print 'Equals 5' if x > 4 :
print 'Greater than 4' if x >= 5 :
print 'Greater than or Equals 5' if x < 6 : print 'Less than 6' if x ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- the if statement and practice problems
- conditional execution
- worksheet conditional iterative
- python selection if else basic selection statement
- 5 conditionals — how to think like a computer
- algorithmic thinking loops and conditionals
- python conditional statements
- python if else and nested if else tutorial kart
- section 3 1 if else
Related searches
- execution the foregoing powers
- strategy execution management software
- project execution strategy
- strategy execution process
- parallel execution python
- execution of ww2 war criminals
- execution of german officers
- execution of nazis
- execution of nazis after war
- execution of socrates
- project execution plan pdf
- sample task execution plan