

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
These lecture notes cover the fall 2012 semester of cpsc 121, focusing on while loop exercises and the computation of a function using both for and while loops. Students are encouraged to review quiz and exam questions, and to read chapter 7 of the textbook by s. Bowers.
Typology: Study notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Lecture Notes CPSC 121 (Fall 2012)
Today ...
Reading
S. Bowers 1 of 2
Lecture Notes CPSC 121 (Fall 2012)
Q: What does this function compute?
def f(n): r = 1 for i in range(1, n+1): r = r * i return r
Q: How can we write this using a while loop?
def f(n): r = 1 i = 1 while i <= n: r = r * i i = i + 1 return r
S. Bowers 2 of 2