Thismaterial provides additional possibilities for the development ofprograms and help to understandthepossibilitiesof buildingprograms ofthelargerscale. As withthe new features, you can create more effective programs.
Chapter9 explains a new type of data and provides information how to workwith this new type. New type is bool, and also two special values:`true` and `false`. In the example below, it is depicted the usage ofthe new type under any circumstances that can get a particular value.
Thistype of data isrequiredfor comparisonsbetweeneach other, aswecan get a report ifcomparative information falls under our comparison or relationaloperator. These comparisons are `==`, `! =`, `>`, `> =`, `<`<= `. With these operators we can compare not only integers butalso symbols and strings.
Moreover,in thechapter also the principle of if-else statementswas considered.In addition, it was shown how the more complex statementsif-elif-else and nested conditionalswork.The following exampleshowsa basic example of if-else statement.
Inthe Chapter 10, you can find the information about loops anditerations. Using loops we can repeat one and the same effect withoutrepeating it in the code. For example, we need to ask the user toenter a certain amount of numbers instead of duplicating code in thesame line of sufficiently put this line in the loop body and set itto the desired number of iterations. It is important to note aboutthe different types of loops: `for` and `while`.
Themain characteristic of ‘for’ is working with a certain number ofiterations which we are mentioning beforehand. For another loop‘while’, we need comparison while loop will be executed.
Thefollowing examples are shown in the figures while and for loops.
Newopportunities ofPython, which were presented in the chapters 9 and 10, addvariabilitytoourprograms. With these features you can build more flexibleapplicationsthan before.Usingloops we can reduce our code (lines that arerepeating severaltimes to replace a line in the loop body and the condition of theloop). Thus,conditionalsmake it possible to check whether the informationis according to standards.
Kindy,M. (2008). Chapter 9: Keyboard input. Python 2: For Beginners Only.Edition1.0. Retrieved from http://cs118.kindy.net/p2fbo_20131230.pdf
Kindy,M. (2008). Chapters 10:Formatted output. Python 2: For Beginners Only. Edition1.0. Retrievedfrom http://cs118.kindy.net/p2fbo_20131230.pdf