Python Control Structures
-----------------------
-change the order of execution
-flow the control of execution(ignore or skip, repeate)
1. Conditional statements (if) - not support switch
2. unconditional statements (break,continue,pass) not support goto
3. looping statements : iteration or repeative statement (for,while) not support do while
1. Python conditional statements:
----------------------------
-control can be transfer into one place to another place with using condition
Python If Statements
-------------------
-check the given input is correct(true) or not(false)
There are various types of if statements in Python.
1. if statement
2. if-else statement
3. nested if statement
4. elseif statements
1. if statements
---------------
-true part only
Syntax:
-------
if(condition):
statements
-----------------------------
2. if...else statements
-----------------------
-true and false
-only one condition
Syntax:
------
if(condition):
statements
else:
statements
----------------------------
working:
----------
-First test condition is evaluated
-if the given condition is true than execute the true part statements
-otherwise execute the else part statement
3. else if statements
---------------------
-more than one condition
Syntax:
------
if(condition):
statements
elif(cond):
statements
elif(cond):
statements
....
....
else:
statements
4. Nested if statements
------------------------
Syntax:
-------
if (condition):
if (condition):
statements
else:
statements
=======================================
-----------------------
-change the order of execution
-flow the control of execution(ignore or skip, repeate)
1. Conditional statements (if) - not support switch
2. unconditional statements (break,continue,pass) not support goto
3. looping statements : iteration or repeative statement (for,while) not support do while
1. Python conditional statements:
----------------------------
-control can be transfer into one place to another place with using condition
Python If Statements
-------------------
-check the given input is correct(true) or not(false)
There are various types of if statements in Python.
1. if statement
2. if-else statement
3. nested if statement
4. elseif statements
1. if statements
---------------
-true part only
Syntax:
-------
if(condition):
statements
-----------------------------
2. if...else statements
-----------------------
-true and false
-only one condition
Syntax:
------
if(condition):
statements
else:
statements
----------------------------
working:
----------
-First test condition is evaluated
-if the given condition is true than execute the true part statements
-otherwise execute the else part statement
3. else if statements
---------------------
-more than one condition
Syntax:
------
if(condition):
statements
elif(cond):
statements
elif(cond):
statements
....
....
else:
statements
4. Nested if statements
------------------------
Syntax:
-------
if (condition):
if (condition):
statements
else:
statements
=======================================
No comments:
Post a Comment