![]() There is pretty much only one conditional statement in Python – the if-else statement. If all else fails, we take the emergency number option in branch 6. What we have done with this program is to instruct the computer to try all these options 1-5 in succession, and when any of them turn a success condition, we take that branch of code and let the computer follow that path. In pseudo-code we can write the situation as, if ( calling_her_friends = success ): follow the path friends tell youĮlse if ( found_fresh_footprints = success ): follow the path where footprints are else if ( ask_others_for_info = success ): vicinity if they have seen her party else if ( call_out_to_the_group = success ): follow the path group informs you else if ( light_a_flare = success ): follow the aid that arrives else: call_emergency_number This situation of a lost hiker at fork in the road, is modeled by the computer program using the conditional statements. How does she decide which path to take to join the rest of the party? We can guess the hiker would try to do any of the following,įind out fresh footprints in the snow/sandĪsk others that maybe hanging out in the vicinity if they have seen her partyĪssuming she tries one or all of these options, it will lead her to choose the path at the fork. Imagine a lost hiker on a trail that has come to a fork in the road. Fork in The Road – Conditional StatementsĬonditional statements show the intent of the programmer, you in this case, to instruct the computer to take one of the available branches of execution. You can download Python package for your platform from the source website and run the tests and programs or the interactive interpreter. While it is vast and complex, enabling platforms like Instagram, and Google operate parts of their websites behind the scenes, Python can be simple and it’s easy to get started. Python is a object oriented, multi-paradigm programming language. In this blog post you will learn to write simple Python programs using conditional logic and if-else statements. ![]() As far as programming languages go, Python is one of the best general purpose languages you can start with and learn to instruct a computer. You may be curious to learn a programming Language. ![]() So if you are curious to learn about how to make your computer say your name out loud when you login everyday morning, or have your computer balance your monthly accounts, or pull a file from the Internet comic strip every day, you have come to the right place. These instructions are what we call a programming language. To tell a computer to perform specific actions to completing a task reliably, and sometimes even repeatedly, it needs to have instructions which are somewhat similar in nature to the recipes used in a kitchen for making delicious food, and a scrumptious meal. Computers do not understand English or Spanish or any other native human language. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |