Lists and Sequences


1.  Make a list of grades.

grades_list = [89, 78, 99, 85]

write a program that prints out the grades, each on its own line.  Use a for loop.

Save this program as

write a program using a for loop that adds up all the elements in the array.  One way to do it is with a variable “total”.

Save this program as

2.  Make a program that asks you for grades and stores them in a list until the user enters a negative number.  (Use a while loop for this, and grades_list.append to get the values into the list. Remember you can make an empty list with

grades_list = [ ]

When you’re done entering grades, have the program find and print out  the average grade.

Save this program as

3.  Write a program ( that asks the user to enter one word at a time, until the user presses “Enter” with no word.   Then the program prints out the words in an alphabetized list, with each word capitalized (whether the user put them in capitalized or not.)


Sequences are like lists, but you can’t add to them or remove stuff from them.   They look the same too, but with parentheses (5, 7. 8) instead of square brackets [5, 7, 8].   One example of a sequence you’ve already seen is colors in the turtle module.  Write a program that asks the user for three numbers between 0 and 255. The first will be the amount of red, the second the amount of green, and the third the amount of blue.  Once the user has entered all three numbers, have the turtle draw a square and fill it with the color entered.  Save this program as

And More…

Make a new program ( that reads the information from a text file.  Use a paper or something you’ve written for another class and print out the words alphabetically.   Make sure you’re reading a text file and not a document.

You might have to copy and paste into a text editor   You may have to look some stuff up to make this work.

And / Or…

Download  Use the code I’ve written to write some kind of card game.  Make sure you understand the code I’ve written first.   You could make BlackJack, or War, or anything you want.  You might not finish, but do what you can.

[/et_pb_text][/et_pb_column][et_pb_column type=”1_3″][et_pb_text admin_label=”Text” background_layout=”light” text_orientation=”left”]


A good website showing some of what you can do with lists.