Untitled
unknown
plain_text
2 years ago
723 B
7
Indexable
list_of_tuples = [('apple', 10), ('banana', 20), ('cherry', 30)]
dictionary = dict(list_of_tuples)
print(dictionary)
tup = (1, 2, 3, 4, 5)
tup1 = (1, 2, 3)
tup2 = (4, 5, 6)
reversed_tup = tup[::-1]
print("Reversed tuple:", reversed_tup)
tup1, tup2 = tup2, tup1
print("First tuple:", tup1)
print("Second tuple:", tup2)
tuple1 = ("Orange", [10, 20, 30], (5, 15, 25))
print("List inside the tuple:", tuple1[1])
tuple1 = ("Orange", [10, 220, 30], (5, 15, 25))
print("Modified tuple:", tuple1)
tuple1 = (10, 20, 30, 20)
a, b, c, d = tuple1
print("a:", a)
print("b:", b)
print("c:", c)
print("d:", d)
count = tuple1.count(20)
print("Occurrence of 20:", count)Editor is loading...
Leave a Comment