Difference between revisions of "CSC111 Loop Exercises 2"

From dftwiki3
Jump to: navigation, search
(Exercise 7)
Line 25: Line 25:
 
  carla is 20 years old.
 
  carla is 20 years old.
 
  alex is 21 years old.
 
  alex is 21 years old.
 +
 +
 +
<font color="magenta">We stopped here in class...</font>
 +
  
 
====Exercise 6====
 
====Exercise 6====

Revision as of 11:06, 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.


We stopped here in class...


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.