A community for students. Sign up today!
Here's the question you clicked on:
 0 viewing
 2 years ago
Question re: PS2, Problem One
My solution to this problem ended up being similar to the given solution, except instead of iterating the for loop through range(0,len(poly)), I choose to iterate directly through "poly". However, this threw an error: "tuple indices must be integers".
My plan was that "for i in poly" would go through each indice in the tuple and assign that particular "i" the value of that indice. I had set up the code to multiply the value of poly[i] by x and then raise it to the value of the indice represented by "i". I didn't think I was modifying the value of the indice
 2 years ago
Question re: PS2, Problem One My solution to this problem ended up being similar to the given solution, except instead of iterating the for loop through range(0,len(poly)), I choose to iterate directly through "poly". However, this threw an error: "tuple indices must be integers". My plan was that "for i in poly" would go through each indice in the tuple and assign that particular "i" the value of that indice. I had set up the code to multiply the value of poly[i] by x and then raise it to the value of the indice represented by "i". I didn't think I was modifying the value of the indice

This Question is Open

snark
 2 years ago
Best ResponseYou've already chosen the best response.0it seems to be saying that you are looking for element tuple[1.5], a fractional index into the tuple. without seeing any code, it's only a guess.

ghostDoctor
 2 years ago
Best ResponseYou've already chosen the best response.0My code was: def evaluate(poly, x): for i in poly: print i sum =+ ((poly[i]*x)*i) print sum and then the value of "poly" was whatever the problem indicated it was, a bunch of floats. i think i assumed that "i" would take the indice value of the tuple, rather than the actual value at that indice.

harsimran_hs4
 2 years ago
Best ResponseYou've already chosen the best response.0what you are doing is perhaps picking up the index and multiplying it by x and the multiplying this product further by the power of x the wrong part is that the value of poly[i] i.e eg 3x2 so in your solution even 3 is getting raised to the power perhaps you should do something like poly[i] * (x**i) well i don`t explain perfectly anything unclear please do ask... i hope this helps!
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.