anonymous
  • anonymous
Hey this is where I am... problem set 2 (1) My thought was to call a function that determined the length of the tuple -- used that information to create an empty list that would than dump the data from the tuple into the list. Call each element in the list and apply their corresponding powers. I'm thinking I need some sort of while or for statement that takes the tuple length and creates the powers. Am I on the right track? I know I could make this super simple but I assumed the point was create a polynomial function that could have a varied length... Sorry about my math vernacular.
MIT 6.00 Intro Computer Science (OCW)
schrodinger
  • schrodinger
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

anonymous
  • anonymous
You're on the right track but you're also making it a bit more complicated than it should be. "For" is a good direction and use the indexes to access tuple elements. Applying powers and accumulating the results shouldnt be hard then.
anonymous
  • anonymous
http://docs.python.org/2.7/library/functions.html#enumerate
anonymous
  • anonymous
for i in range(len(tuple)): list[i] = tuple[i] will give you a list, but I think the only advantage here is that you can change the list values directly. there is also a one line version list = [element for i in range(len(tuple))]

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
On the third problem do you want to embed the function you created in the first problem?
anonymous
  • anonymous
Ok i'm still struggling with this code -- I think it's basically because I'm not writing the functions correctly. But I can't seem to add or change the list via call the locationn in the list. while guessedValue == k: print 'got here' print rangeBegin print unguessList unguessList = unguessList.insert(rangeBegin,guessedValue) print unguessList del unguessList[rangeBegin:rangeBegin] if guessedValue == k: guessCorrect = 1 else: guessCorrect = 0 All I want is for list to be checked and if it matches remove the '*" and add the called letter. There seems to be no embedded function that does this...
1 Attachment
anonymous
  • anonymous
You don't need to do this: for i in range(len(tuple)): list[i] = tuple[i] use list = tuple [:] (clonning) You're using tuples, use them to simplify your task, take one for the letters of the word, another one with the wrong guess, and another with the good guess, using that tuples you can make a cleaner comparison; and I think that another definition about list_maker can be avoided, but it's ok anyway.
anonymous
  • anonymous
if i do that won't that just insert the entire tuple into the spot [o] on the list?
anonymous
  • anonymous
no, doing this "list = tuple [:]" will be exactly the same, and if you do list == tuple, will say True. if you do, for list[i] = tuple[i]; will look the same, but list == tuple, will say False
anonymous
  • anonymous
so i want to use (ex. list_sample = tuple_sample[:]) this will create list that is identical (for all intents and purposes to a tuple)
anonymous
  • anonymous
that's what I'm saying, clonning, why don't you try it on your Python shell so can be more familiar.
anonymous
  • anonymous
will do this should make things a bit easier :) thanks!
anonymous
  • anonymous
you're welcome!

Looking for something else?

Not the answer you are looking for? Search for more explanations.