Python: Selection, Booleans and Libraries - Cambridge Lower Secondary Class 8 Computing Notes, Diagrams and Solved Questions

Write Python programs that use Integer, Real, String and Boolean data, convert input, make decisions with if, elif and else, combine conditions with and, or and not, and use program libraries such as math and random.

In this chapter

  • The data types Integer, Real, String and Boolean, and choosing the right one
  • Converting input with int(), float() and str()
  • Selection with if and else, and the difference between = and ==
  • More than two choices with elif
  • Rules using and, or and not in Python
  • What program libraries are and why programmers use them
  • Using library and built-in functions: math.sqrt, round, len, random.randint
  • Exam-style questions: predicting output and writing short programs