Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Python Lists: What are they? How do you add items to a list (.append(), .inse

ID: 3721580 • Letter: I

Question

In Python

Lists:
   What are they?
   How do you add items to a list (.append(), .insert())
   How do you remove things from a list (.pop(), and .pop(index))
   How do YOU search a list? (writing code that does this, not using native functions)
   How do YOU sort a list? (writing code that does this, not using native functions)
   What are the different ways to search and sort a list that we discussed in class? Can you code them?

Dictionaries:
   What are they?
   How do you access an individual value based on its key?
   How do you change/set a key to a particular value?
   How do you get access to all of the keys of a dictionary?
   How do you get access to all of the values of a dictionary?

Tuples:
   What are they?
   How do you create a tuple?
   Can you add items to a tuple?
   How do you check to see if an item is in a tuple?

Explanation / Answer

Answer:

Wha are Tuples:

A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets.

How do you create a tuple?

Creating a tuple is as simple as putting different comma-separated values. Optionally you can put these comma-separated values between parentheses also. For example ?

The empty tuple is written as two parentheses containing nothing ?

To write a tuple containing a single value you have to include a comma, even though there is only one value ?

Like string indices, tuple indices start at 0, and they can be sliced, concatenated, and so on.

Can you add items to a tuple?
You can't add elements to a tuple because of their immutable property. There's noappend() or extend() method for tuples, ... You can find elements in a tuple since this doesn't change the tuple. You can also use the in operator to check if an element exists in the tuple.

How do you check to see if an item is in a tuple?

You use in.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote