Before you start, make a folder called “Lists” in your IDE. Put all the work for this chapter in that folder.
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 lists0.py
write a program using a for loop that adds up all the elements in the list. One way to do it is with a variable “total”.
Save this program as lists1.py
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 lists2.py
3. Write a program (lists3.py) 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.)
Make a new program (lists4.py) 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…
Make a card game. 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.
A good website showing some of what you can do with lists.