Difference between revisions of "CSC111 Loop Exercises 2"
(Created page with '==Exercises on Loops and Sequences== ====Exercise 1==== Get 5 numbers from the user and store them in a list ====Exercise 2==== Same questions with 20 numbers. (explore com…') |
|||
Line 1: | Line 1: | ||
+ | __NOTOC__ | ||
==Exercises on Loops and Sequences== | ==Exercises on Loops and Sequences== | ||
Revision as of 08:45, 5 February 2010
Exercises on Loops and Sequences
Exercise 1
Get 5 numbers from the user and store them in a list
Exercise 2
Same questions with 20 numbers. (explore combining Python statements...)
Exercise 3
Same exercise, but this time the user is first asked how many numbers she wants to record.
Exercise 4
Create a list of students, where we keep track of both the student name, and his/her age. Just print the raw list to verify that it contains all the names and all the ages.
Exercise 5
Same as Exercise 4, but this time the program will print the student information in a nice format, as follows:
nicolas is 19 years old. carla is 20 years old. alex is 21 years old.
Exercise 6
Generate the list of all the 111c-xx accounts: 111c-aa, 111c-ab, ... 111c-az.
(Hints: for Python, we can treat "abcde" the same way we treat [ 'a', 'b', 'c', 'd', 'e' ] )
Exercise 7
Approach the Old MacDonald exercise from the lab using a top-down approach.