Python Beginners Tutorial | Collections TUPLE | Basic Programming 6

preview_player
Показать описание
________ ONLINE COURSES TO LEARN ________

There are 4 Collection data types in Python

List | Tuple | Set | Dictionary

List [] ordered | indexed | changeable | duplicates
Tuple () ordered | indexed | unchangeable | duplicates
Set {} unordered | unindexed | no duplicates
Dictionary {K:V} unordered | changeable | indexed | no duplicates

Code - Tuple

my_tuple = ("Apples", "Oranges", "Grapes")

print(my_tuple)
print(my_tuple[1])
print(my_tuple[-1])
print(my_tuple[0:2])

for val in my_tuple:
print(val)

# my_tuple[3] = "Cherry"
# del my_tuple

print(len(my_tuple))

my_tuple_2 = ("Banana",(1,2,3),["Tokyo","New Delhi"])
print(my_tuple_2)
print(my_tuple_2[2][1])

my_tuple_2[2][1] = "New York"
print(my_tuple_2)

print("Banana" in my_tuple_2) # True
print("Cherry" in my_tuple_2) # False

#PythonBeginnerTutorials #PythonCollections #Tuple

ONLINE COURSES TO LEARN

------------ UI TESTING ------------

------------ API TESTING ------------

------------ MOBILE TESTING ------------

------------ CI | CD | DEVOPS ------------

------------ VERSION CONTROL SYSTEM ------------

------------ PERFORMANCE TESTING ------------

------------ JAVA ------------

------------ MAVEN ------------

------------ OTHERS ------------

------------ Follow ------------
Рекомендации по теме
Комментарии
Автор

what is the difference between list and tuple? when and why we should use list or tuple?

pnkjgupta
Автор

Hi Raghav,
If we have" Strings and Numbers" both in a tuple and i need to print string only. Kindly help.

abhishekdubey
join shbcf.ru