Exercises
September 18 - September 22, 2006
To ensure that you receive appropriate laboratory credit, for each
exercise make sure that I have looked at your source code and seen
a demonstration of your working program.
- Write a while loop that prints all of the even numbers between 1 and
100.
Create two versions of this loop, one that uses an if statement and one
that does not.
- Write a program that uses the module random to select a
random number between 1 and 10 (example below) and asks the user to
repeatedly enter
a number until he/she has guessed the random number.
#import the module random
import random
#call the randint function passing in the range
num = random.randint(1, 10)
- Design a program which prompts the user for a number of rows between
0 and 10 and prints the following pattern:
****
***
**
*
- Design a program which prompts the user for a number of rows between
0 and 10 and prints the following pattern:
*
* *
* * *
* * * *
Sami Rollins