-
Book Overview & Buying
-
Table Of Contents
Python Illustrated
By :
We can use Python to do lengthy calculations for us. Imagine we need to calculate 1+2+3+4+5+6+.... If we had to do that from the top of our heads, it would take quite some time. Of course, there’s a smart and exciting mathematical way to solve such a problem, but I’ll keep a lid on that. You’re going to write a program that calculates the sum of all numbers from 1 to 10 using a for loop, and print the result.
Given a list of names, print each name with a greeting:
names = ["Zia", "Wiesje", "Muchu"]
Wiesje loves to chase squirrels; if she had infinite energy (and never got distracted), she probably would like to do it forever. Let’s recreate this scenario in Python.
Create an infinite loop that prints "Wiesje chases the squirrel!" over and over again.
Let’s stop that loop and rewrite our...