Python Programing: An Introduction to Computer Science
Python Programing: An Introduction to Computer Science
Chapter 11 Data Collections
Python Programming, 2/e
1
Objectives
n To understand the use of lists (arrays) to represent a collection of related data.
n To be familiar with the functions and methods available for manipulating Python lists.
n To be able to write programs that use lists to manage a collection of information.
Python Programming, 2/e
2
Objectives
n To be able to write programs that use lists and classes to structure complex data.
n To understand the use of Python dictionaries for storing nonsequential collections.
Python Programming, 2/e
3
Example Problem: Simple Statistics
n Many programs deal with large collections of similar information.
n Words in a document n Students in a course n Data from an experiment n Customers of a business n Graphics objects drawn on the screen n Cards in a deck
Python Programming, 2/e
4
Sample Problem: Simple Statistics
Let's review some code we wrote in chapter 8:
# average4.py # A program to average a set of numbers # Illustrates sentinel loop using empty string as sentinel
def main(): sum = 0.0 count = 0 xStr = input("Enter a number ( to quit) >> ") while xStr != "": x = eval(xStr) sum = sum + x count = count + 1 xStr = input("Enter a number ( to quit) >> ") print("\nThe average of the numbers is", sum / count)
main()
Python Programming, 2/e
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- an introduction to marketing pdf
- introduction to computer systems pdf
- an introduction to moral philosophy
- introduction to computer studies pdf
- introduction to computer science
- introduction to computer packages pdf
- introduction to computer pdf notes
- introduction to computer science free
- introduction to computer science class
- an introduction to an essay
- introduction to computer science course
- introduction to computer science online