CONDITIONAL STATEMENTS IN PYTHON - GitHub Pages
[Pages:23]CONDITIONAL STATEMENTS IN PYTHON
Peter Larsson-Green J?nk?ping University Autumn 2018
CONDITIONAL STATEMENTS
Enter a number: 12 That is a positive number!
Enter a number: -12 That is a negative number!
BOOLEANS
? Used to represent something's correctness. ? Possible values: True and False. Examples
True True True False False False
RELATIONAL EXPRESSIONS
Syntax: How it is computed
1. Evaluate .
Examples
2. Evaluate .
3. Apply on the computed values.
3 < 5 3 < 5 3 < 5 3 < 5 True
3 > 5 3 > 5 3 > 5 3 > 5 False
3 == 2 3 == 2 3 == 2 3 == 2 False
3 != 2 3 != 2 3 != 2 3 != 2 True
RELATIONAL EXPRESSIONS
Examples
5 = 5
5 = 2
5 = 2 True
THE IF STATEMENT
Conditionally executes statements.
Syntax
if :
Statement 1
Statement 2
Statement ...
How it is executed
1. Evaluate .
True
False
2. Execute
2. Go to next
. statement.
3. Go to next statement.
THE ELIF STATEMENT
? elif is short for else if.
? Optional continuation of an if/elif statement.
How it is executed
1. Evaluate .
True
False
Syntax
if :
Statements-a
elif :
Statements-b
2. Execute
2. Evaluate
. .
3. Go to next statement.
True
False
3.
Execute .
3.
Go to next statement.
4. Go to next statement.
................
................
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 functions tutorial kart
- python syntax quick reference for some like it tepid project
- conditional statements in python github pages
- python cheat sheet
- python tutorial cheat sheet new york university
- basic python syntax college of engineering
- python language syntax cheat sheet 101 computing
- python if else and nested if else tutorial kart
- control statements
- the python language reference university of idaho
Related searches
- conditional statements verilog
- conditional statements and equivalence
- conditional statements and equivalence quiz
- conditional statements venn diagram worksheet
- conditional statements quizlet
- multiple return statements in python function
- conditional statements in word
- multiple conditional statements in excel
- conditional statements and equivalence quizlet
- conditional statements examples
- conditional statements geometry definition
- conditional statements geometry pdf