0% found this document useful (0 votes)
58 views

Tuples in Python

The document discusses different data structures in Python including tuples, lists, dictionaries, and sets. Tuples are ordered collections that are immutable and defined using parentheses. Common tuple operations include accessing elements by index, finding length, concatenating tuples, and repeating tuples. Tuples also support functions like min() and max() to find minimum and maximum values.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Tuples in Python

The document discusses different data structures in Python including tuples, lists, dictionaries, and sets. Tuples are ordered collections that are immutable and defined using parentheses. Common tuple operations include accessing elements by index, finding length, concatenating tuples, and repeating tuples. Tuples also support functions like min() and max() to find minimum and maximum values.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Data structure in python :-

- Tuples
- List - sequence, duplicates allowed, mutable(can change / modify)
- Dictionary
- Set - non-sequence, duplicate not allowed

list1 = [4,5,6,7,8,8]
mySet = set(list1)
print(mySet) = {4,5,6,7,8}

Tuples :-
Tuples is an ordered collection of elements enclosed within ().
Tuples are immutable (once created cannot be update(change))

tup1 = (1, 'a', True, 4.7)


=> first element
tup1[0] // 1
=> last element
tup1[-1] // 4.7
=> sequence of element
tup1[1:3] // 'a', True,

=> you cannot modify a tuple because it is immutable


tup1[2] = "test" // error

=> Finding length of Tuple


len(tup1) // 4

=> concatenating tuples (join two tuples)


tup1 = (1,2,3)
tup2 = (4,5,6)
tup1+tup2
output => (1,2,3,4,5,6)
also tup2+tup1

=> Repeating tuple elements or Repeating with concatenating


tup1 = ('test', 500)
tup1*3
('test', 500,'test', 500,'test', 500)

=> Tuple functions


minimum value :-
min(tup1)
maximum value :-
max(tup1)

ASCII(American standard code for information interchange)


a=97 +26 = 122(z)
A=65 +26 = 90(Z)
0 = 48 + 9 (57)

You might also like