Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

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)
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.

Join Brainly to access

this expert answer

SEE EXPERT ANSWER

To see the expert answer you'll need to create a free account at Brainly

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.
http://docs.python.org/2.7/library/functions.html#enumerate
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))]

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

On the third problem do you want to embed the function you created in the first problem?
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
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.
if i do that won't that just insert the entire tuple into the spot [o] on the list?
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
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)
that's what I'm saying, clonning, why don't you try it on your Python shell so can be more familiar.
will do this should make things a bit easier :) thanks!
you're welcome!

Not the answer you are looking for?

Search for more explanations.

Ask your own question