Difference between revisions of "Looping Exercises"
From WLCS
Line 1: | Line 1: | ||
'''Objective:''' | '''Objective:''' | ||
* To become well-learned in the way of the while loop | * To become well-learned in the way of the while loop | ||
+ | |||
+ | '''Resources:''' | ||
+ | * [http://openbookproject.net/thinkcs/python/english2e/ch06.html HTTLACS: Ch 6 - Iteration] | ||
'''Directions:''' | '''Directions:''' |
Revision as of 13:08, 11 February 2011
Objective:
- To become well-learned in the way of the while loop
Resources:
Directions:
- For each of the following sequences, first prompt the user for a number N and print out the first N terms of the sequence
- Creating functions for the following exercises is optional
- Use while loops to generate the following sequences
- Powers of 2
- 1, 2, 4, 8, 16, 32, 64, 128, ...
- Fibonacci Sequence (HINT: use multiple variables)
- 0, 1, 1, 2, 3, 5, 8, 13, 21, ...
- Factorial Sequence (HINT: use multiple variables)
- 1, 1, 2, 6, 24, 120, ...