Class Notes (836,215)
Computing (443)
CISC 121 (27)
Lecture

# 2.1.pdf

2 Pages
110 Views

School
Department
Computing
Course
CISC 121
Professor
Robin W Dawes
Semester
Winter

Description
2.1 Tuesday, January 15, 2013 9:35 AM Suppose we frequently wish to print the line "We've got rocks and trees"The arrogant worms Aside: Range possibilities range(6) = range(0, 6) = [0, 1, 2, 3, 4, 5] Print " We've got rocks and trees" range(1, 6) = [1, 2, 3, 4, 5] Print" We've got rocks and trees" Blah blah blah Print " We've got rocks and trees" Print" We've got rocks and trees" Print " We've got rocks and trees" Print" We've got rocks and trees" Simplification - Create a function to do the printing, referring to it whenever we need to print. Python function writing* def rocks_trees(): print "We've got rocks and trees" Calling: rocks_trees() Even easier: def rocks_trees(numloop) for j in range (n): print "we've got rocks and trees" Call: rocks_trees(4) Another example: def average(
More Less

Related notes for CISC 121
Me

OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Just a few more details

So we can recommend you notes for your school.