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

PatrickD Group Title

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.

  • one year ago
  • one year ago

  • This Question is Closed
  1. Ante Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

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

    http://docs.python.org/2.7/library/functions.html#enumerate

    • one year ago
  3. shawnf Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

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

    • one year ago
  4. PatrickD Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    On the third problem do you want to embed the function you created in the first problem?

    • one year ago
  5. PatrickD Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

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

    • one year ago
    1 Attachment
  6. Gianko15 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    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.

    • one year ago
  7. PatrickD Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    if i do that won't that just insert the entire tuple into the spot [o] on the list?

    • one year ago
  8. Gianko15 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    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

    • one year ago
  9. PatrickD Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    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)

    • one year ago
  10. Gianko15 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    that's what I'm saying, clonning, why don't you try it on your Python shell so can be more familiar.

    • one year ago
  11. PatrickD Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    will do this should make things a bit easier :) thanks!

    • one year ago
  12. Gianko15 Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    you're welcome!

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