Uploaded by Anthony Smith

CS Review for Final Exam

advertisement
CS 153 / 453 Review for the Final Exam
Recent chapters will be the focus of the exam. The exam is cumulative. I recommend that you review your
previous exams and programming assignments; and do the practice exercises provided in Module M 12.
Chapter 8
Lists
range function
Using functions: len, min, max, sum, and sort
Using list methods, especially these:
 append( )
 extend( )
 insert( )
 remove( )
 pop( )
 count( )
 find( )
Iterating over a list using a list index
Iterating over the elements of a list using the in operator
List slicing
List comprehensions
Chapter 12
Reading from files
open( ) , 'r' mode
read( )
readlines( )
readline( )
for line in myfile: (iterating over a file) *
close( )
Writing to files
open( ) , 'w' mode
write( )
writelines( )
writeline( )
close( )
*Note: The for loop is the preferred way to read an input file (one line at a time).
Chapter 15
import matplotlib.pyplot as plt
Creating a line plot with plt.plot
list of x values
list of y values
xlabel
ylabel
title
setting color of the line
grid
putting text on the plot
Creating a bar chart with plt.bar
list of x values (left positions of bars)
list of y values (heights of bars)
setting width of bars
setting color of bars
xlabel
ylabel
title
Creating a pie chart with plt.pie
list of slices (numbers for size of slices)
list of labels (strings to label the slices)
list of colors
explode
startangle
Download