A community for students. Sign up today!
Here's the question you clicked on:
 0 viewing
 2 years ago
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
 2 years ago
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

This Question is Closed

snark
 2 years ago
Best ResponseYou've already chosen the best response.1the 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...)

tcc8m
 2 years ago
Best ResponseYou've already chosen the best response.0Thanks snark exactly what I was looking for.
Ask your own question
Ask a QuestionFind more explanations on OpenStudy
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
 Engagement 19 Mad Hatter
 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.