HomePython Python 101 (part 3): A Twist In The Tail
Python 101 (part 3): A Twist In The Tail
Find out more about adding flow control to your Python programswith the "for" and "while" loops, see how the range() function can be usedto generate number ranges, and learn all about list objects. And bring anold flame along for the ride.
Last time out, I taught you a little bit about two of Python's basic datatypes, strings and numbers. I also gave you a crash course in Pythonoperators and expressions, and demonstrated how they could be used inconjunction with the "if" family of conditional statements to add controlroutines to your Python programs.
However, "if" statements are only one piece of the jigsaw; Python alsoallows you to control program execution with the "while" and "for" loops,which coincidentally also happen to be the subject of today's discussion.Along the way, I'll be demonstrating yet another of Python's built-in datastructures, visiting the Superhero Hall Of Fame, hooking up with some oldflames, and examining prime numbers and factorials.