Quantcast

A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

Ante

  • 2 years ago

Hello guys! I noticed that Guttag uses lists in many cases where - seemingly - tuples would work as well. When I write code I'm trying to avoid mutable data objects whenever it's possible but I was just wondering if there's any particular reason why lists may be preferable in general? (Maybe something about memory requirements? )

  • This Question is Closed
  1. harsimran_hs4
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    lists in general are more easier to work and handle......you can easily refer to an element, pop out a element from list , add elements , overwrite elements(replace with new ones) etc. certainly all these features are not available in tuples and lists have an advantage where we need to constantly modify the stored data be it add elements or refer to them. as regarding memory requirements someone else may better answer it

  2. RONNCC
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    tuples have a memory advantage I think

  3. RONNCC
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    lists are dynamically sized, tuples are not

  4. KonradZuse
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    It seems like a tuple would be an array(n-tuple)? I've heard the term in discrete and calc and such. From above it says tuples cannot modify the data within(stacks,queues,etc) but Arrays can... Arrays aren't a list I don't believe.

  5. shawnf
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    A list takes up more bytes than a tuple, and a tuple is immutable. That would seem to argue for using tuples unless you need to be able to append or assign values to elements. I find lists easier to work with.

  6. MicroBot
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    not sure why prof. Guttag uses list over tuples but the following link gives some info about their differences and uses. http://news.e-scribe.com/397 hope it helps

  7. Muscy
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Lists vs Tuples is very much about what you need them for, If you want a variable that you do not want to accidentally change use a tuple for constants, (For style, constants variable names are written in uppercase i.e. EARTH_RADIUS = 6 378.1) If you want to change / add to / remove from you need mutability, a list would be better.

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

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

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.