Course No Module

  • Uncategorized

CourseNo:

Module

Case ITM205-SLP3

Theseexamples show the new programming examined in action. Hereyou can see howconditionalsare workingand as one of the conditional can be replaced by a logicalalternative.Moreover, after thisexcanging the result oftheprogram will not change. In the example,there isshown replacement of 9&gt5 to5&lt9. In another example,there isshown work `for` loop. Furthermore,using loop the quite large work can be done very compactly.

Insteadof repetitions of the same line of code from counting the number ofletters it is donewith oneline in the body of the loop. Checkingtheseexamples,the usingof loops and conditionals becomes moreunderstandable andclear.

Tosum up, using loops, conditionals and if-else statements makes thework easier and more understandable.

Course No Module

  • Uncategorized

CourseNo:

Module

Case ITM205-Case3

Thismaterial provides additional possibilities for the development ofprograms and help to understandthepossibilitiesof buildingprograms ofthelargerscale. As withthe new features, you can create more effective programs.

LessonLearnt

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 `==`, `! =`, `&gt`, `&gt =`, `&lt`&lt= `. 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.

Conclusion

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.

Reference

Kindy,M. (2008). Chapter 9: Keyboard input. Python 2: For Beginners Only.Edition1.0. Retrieved from&nbsphttp://cs118.kindy.net/p2fbo_20131230.pdf

Kindy,M. (2008). Chapters 10:Formatted output. Python 2: For Beginners Only. Edition1.0. Retrievedfrom&nbsphttp://cs118.kindy.net/p2fbo_20131230.pdf

Close Menu