Skip to main content
Ctrl+K
Jörg Faschingbauer - Home Jörg Faschingbauer - Home
  • Training Courses
  • About
  • Blog
  • Training Courses
  • About
  • Blog

Section Navigation

  • Course Descriptions
  • Pricing, Organizational
  • Log Of Past Courses
  • Complete Slide Material
    • Linux
    • Python Programming
      • Python: The Language Fundamentals
      • Python: More Language Features
      • Python: Project/Package Management
      • Python: Miscellaneous Topics
      • Python: Draft Topics
      • Python Links
      • Exercises
        • Exercises (Legacy)
        • Exercises (External)
        • CSV and Databases
        • User Database (Exercise Series)
        • Sensors, And Data Acquisition (Exercise Series)
    • The C Programming Language
    • C++ < 11
    • C++ >= 11
    • Design Patterns With C++
    • C++: TODO List
    • C++: Miscellaneous Live-Hacking
    • C++ Code
    • C++ Exercises
    • CMake
    • Is Software A Craft? Software Is A Craft! ⟶ Clean Code
    • Unit Testing With googletest
  • Training Courses
  • Complete Slide Material
  • Python Programming
  • Exercises
  • Exercises (Legacy)
  • Exercise: Primeness (for)

Exercise: Primeness (for)#

See also

  • Commandline Arguments (sys.argv)

  • Datatypes (“Datatype Conversions”)

  • for Loops

  • The range Function

Convert the program from exercise Exercise: Primeness (while) as follows.

  • Use a for loop instead of a while loop

  • Use the range() function to specify the range of divisor candidates

Compare both while and for solutions. Which one appears more readable?

© Copyright 2019-2025 (GPLv3), Jörg Faschingbauer.

Created using Sphinx 8.1.3.

Built with the PyData Sphinx Theme 0.16.1.

Show Source