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: 5

No comments:

All Rights Reserved by Technology from Developers Eye © 2014 - 2015
Powered By Blogger, Designed by Aadics
Disclaimers:: The information provided within this blogsite is for general informational purposes only. While we try to keep the information up-to-date and correct, there are no representations or warranties, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the information, products, services, or related graphics contained in this blogsite for any purpose.The author does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause.

Contact Form

Name

Email *

Message *

Powered by Blogger.