Decision making in Python
As other languages Python also support conditional flow
for the control which can be controlled depending on whether a condition
evaluates to true or false
Syntax
if condition_1:
statement_block_1
elif condition_2:
statement_block_2
else:
statement_block_3
Benefits/Usages
Dynamic content rendered on separate page
Code cleanliness more manageable,
Master / child page structure can be achieved
Code Snippet
userNumber
= input('Give me an integer number: ')
userNumber = int(userNumber)
print
if userNumber < 5:
print
"adolescence period!"
elif userNumber <13 and userNumber>5:
print
"Chilhood"
elif userNumber >=13 and userNumber < 20:
print
"Teen age"
elif userNumber >= 20:
print
"Adult age "")
Decision making in Python
Reviewed by Rupesh
on
22:40
Rating:
No comments: