Difference between revisions of "CSC111 Loop Exercises 2"
(→Exercise 7) |
|||
Line 36: | Line 36: | ||
Approach the Old MacDonald exercise from the lab using a top-down approach. | Approach the Old MacDonald exercise from the lab using a top-down approach. | ||
+ | |||
+ | <br> | ||
+ | <br> | ||
+ | <br> | ||
+ | <br> | ||
+ | <br> | ||
+ | <br> | ||
+ | <br> | ||
+ | <br> | ||
+ | <br> | ||
+ | <br> | ||
+ | <br> | ||
+ | <br> | ||
+ | <br> | ||
+ | <br> | ||
[[Category:CSC111]][[Category:Exercises]] | [[Category:CSC111]][[Category:Exercises]] |
Revision as of 08:46, 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.