CS 111 - 4/12/18
Prof. Troy's Office Hours for Today (Thursday 4/12/18) will
be pushed back to run from 2:15 - 3:45.
For loops - typically used when the loop will execute a
set number of times.
We can implement while instead of for loops (as we have been
doing so far in the class).
In Python, the for loop normally is used with the range() function
call.
The range() function, produces a list of values based on
the three parameters to the range() function
range ( initialValue, stopValue, incrementValue )
To create the values from 0 to 9 inclusive, the following
range() function could be used:
range ( 0 , 10 , 1 )
Note that the stopValue is one more that the last value placed
into the list of values created by the range() functions
There are 2 special forms of the range function:
#1: when only 2 parameter values are given
range ( intialValue, stopValue )
in this form, the incrementValue is assumd to be 1
#2: when only 1 parameter values are given
range ( stopValue )
in this form, the incrementValue is assumed to be 1
and the intialValue is assumed to be 0
To use the range() function with a for loop, the syntax is
typically as follows:
for loopCounterVariable in range ( 0, 10, 1 ) :
# loop body
print loopCounterVariable
The corresponding while loop for the above for loop would be:
loopCounterVariable = 0
while ( loopCounterVariable < 10 ):
# loop body
print loopCounterVariable
loopCounterVariable = loopCounterVariable + 1
Sound
volumne increade/decrease
fade-in
blend tow sounds together ( play at the same time )
"add" the two sample values together