Name: ______________ Net id: _____________ || Name: ______________ Net id: _____________ Name: ______________ Net id: _____________ || Name: ______________ Net id: _____________
third
and fourth
? What are the similarities?
cat
and bird
are similar,
what are the differences in the functions?
birdverse
cannot be
moved inside the function third
. If you
cut/copy/paste it inside third
, what does Eclipse
tell you?
a1
and a2
appear
in both bird
and third
-- provide a
plausible explanation of why this is ok and doesn't cause
confusion in the Python interpreter.
fourth
using the
the nesting technique in your working version of the program. What
are the last three lines of the function you wrote?
Modify the Python code by adding appropriate functions in the same style as those you're given to print the new verse below in addition to all the verses that are already printed. What are the names of the new functions you wrote? What are the last three lines of the function you wrote that contains a nested function?
location
is initialized
to 0 and to 80 when the program is run? Why?
visual
in the function main
. Here's the
function you should write in RandomWalk.py
-- then
call this function appropriately from main
:
split
and the
variable
steps
in the code above?
analyze
from main
?
analyze
so that it prints the
bug's location that's farthest to the right using the code
below. Then answer the questions about the code.
find
do?
locs
in the
code above?
max
do?
sum
returns the sum of all numbers in a
list. Find the average value of the bug's location during a
walk by writing Python code. What's the code?
What's the
average value in a random walk of 1000 steps?
make_verse
returns two things, both are
functions. What are the clues in the return statement and
in the function call that two things are returned?
main
that the return values are functions and
not strings?
make_verse
that will result in
generating the verse about the woman eating a dog?
How will you
use the returned values to print the verse?
make_verse
. Here's a new version of
main
that you should try to finish and about which
you'll answer questions.
make_verse
. Add them so the program runs using
this loop. What did you add?
lastverse
? What
type of value does it hold?