filmov
tv
Python Beginners Tutorial | Collections TUPLE | Basic Programming 6

Показать описание
________ 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 ------------
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 ------------
Комментарии