Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

tcc8m

Hi I have a question about Quiz 1 #5. Why do you need to insert the two lines at the bottom for the function to meet its specification? Check out my pastebin: http://pastebin.com/HJxRKWw0

  • one year ago
  • one year ago

  • This Question is Closed
  1. snark
    Best Response
    You've already chosen the best response.
    Medals 1

    the problem is that when you set result = v1 both result and v1 refer to the same address in memory - if you modify result, you also modify v1, but you are told not to modify the inputs. to avoid doing this, a copy of v1 and v2 is made: v1 = v1[:] v2 = v2[:] these are assigned new addresses in memory distinct from the v1 and v2 in the function call addVectors(v1,v2). (this would be clearer had he given them new names - w1 = v1[:] but maybe that's his point...)

    • one year ago
  2. tcc8m
    Best Response
    You've already chosen the best response.
    Medals 0

    Thanks snark exactly what I was looking for.

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.