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

2.1.pdf

2 Pages
110 Views
Unlock Document

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

Log In


OR

Join OneClass

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

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit