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
- python tutorial stanford artificial intelligence laboratory
- the zen of python
- programming in python
- python question and answers built in functions
- ©2012 2013 laurent pointal mémento v1 2 2 python 3 cheat
- introduction to python day 1 3
- example true false questions computer science
- loops and iteration open michigan
- conditional execution
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