Tuples in Python: .index(), .count(), len() - Series A

Опубликовано: 07 Август 2026
на канале: Doug Morrow
161
2

In this video, I go over the basics of how to work with Tuples in Python. I am not an expert when it comes to Python, but I know that teaching a subject helps solidify the information learned about.

This is Series A
Series A = 1
Series B = 2

Each series is intended to be better than the last because of all the practice I'll get in creating them.

✔ Other Places to Connect:
My Website: https://dougm.io/

✔ Support Through Patreon:
https://www.patreon.com/user?u=322207...

✔Learn More about Lists at - w3schools
https://www.w3schools.com/python/pyth...

✔Additional Practice Questions
https://github.com/MorrowG2/YouTube_P...

✔Practice Questions
https://github.com/MorrowG2/YouTube_P...

---------------------------------------------------------------------------------------------------------------
Questions

Tuple

my_tuple = (1, 2, 3, 4, 2, 5, 2, 6)

print(len(my_tuple))

Think immutable list.
in
Tip: Tuples are faster than lists.
slicing a tuple
a,b,c *rest = (1, 2, 3, 4, 2, 5, 2, 6)
.count() .index(), len()

1. Can you think of any metaphors for a tuple?
2. Which is faster a tuple or a list?
3. What is an immutable item? (In programming.)
---------------------------------------------------------------------------------------------------------------
4. Create 8 tuples with different variables
Example:
my_tuple = (1, 2, 3, 4, 5)
Note: Tuples are just like lists, but Tuples are faster and immutable
You can use strings, integers, and boolean values.
---------------------------------------------------------------------------------------------------------------
5. For this task, your goal is to return a boolean value (True/False)
Check to see if the tuples you've created are in... cough, cough, your tuple:
Check each of the values (1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 'a', 'b', 'c', 's', 'e', 'i', "('_')", "(*-*)", ':P')
---------------------------------------------------------------------------------------------------------------
6. What does * do? Do you need to use * with a variable?
Use the 8 tuples you've created and bind each value to a separate variable
Delete two variables from each of the 8 tuples and use * with a variable to view the values as a list.
Look at the very top of this script to see my example of how to use *
---------------------------------------------------------------------------------------------------------------
7. How many times does the following values show in your 8 tuples? What's the number of occurrence? (Pretty
much asking the same question but trying to "HINT" the proper method to use.)
How often do the following show in your code?
(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 'a', 'b', 'c', 's', 'e', 'i', "('_')", "(*-*)", ':P')
---------------------------------------------------------------------------------------------------------------
8. Use the values below to see which 'position' each value shows up in your 8 tuples.
(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 'a', 'b', 'c', 's', 'e', 'i', "('_')", "(*-*)", ':P')
---------------------------------------------------------------------------------------------------------------
9. Count the total number of values in each tuple.
What might the length of each tuple be?
How could you count it? (The length)