Got a YouTube account?


English subtitles

← Replace Spy - Intro to Computer Science

Get Embed Code
6 Languages


  1. [Narrator] For this quiz your goal is to define a procedure named replace_spy
  2. that takes as its input a list of 3 numbers and modifies the value of the third element
  3. in input list to be 1 more than its previous value.
  4. To solve this quiz you're going to have to
  5. experiment and understand how values are past procedures in Python.
  6. Something we haven't talked about yet, but if you solve this quiz
  7. you'll have a good understanding of how things might work.
  8. The behavior that we want is shown in an example,
  9. so if the value of spy is the list 0, 0, 7,
  10. we call the procedure replace spy, passing in spy.
  11. Note that we're not using the result.
  12. We're not assigning this back into a variable spy.
  13. We're just calling replace spy, but after the call
  14. the value that spy refers to has changed.
  15. Now it has the value 0, 0, 8.
  16. So, I haven't yet told you what it means to pass a mutable object
  17. like a list to a procedure, but try to define replace spy
  18. and see if you can figure out what happens.