-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTuples.py
More file actions
42 lines (33 loc) · 728 Bytes
/
Tuples.py
File metadata and controls
42 lines (33 loc) · 728 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Program to demonstrate tuples
# Declare tuples
tup1 = ("Gallen", "Jeremy", 38, "Texas")
tup2 = ("Coryell", "Copperas Cove")
tup3 = (17, 5, 8, 10, 1)
# Display type
print(type(tup1))
# Print tuple
print(tup1)
# Print individual tuple elements
print(tup1[0])
print(tup1[1])
print(tup1[2])
print(tup1[3])
print(tup1[-1])
print(tup1[-2])
print(tup1[-3])
print(tup1[-4])
# Print tuple ranges
print(tup1[0:1])
print(tup1[2:3])
# Display tuple sizes
print(len(tup1))
print(len(tup2))
# Add tuples
print(tup1 + tup2)
print(tup2 + tup1)
# Repeat tuple elements
print(tup1*3 + tup2*2)
print(tup2*4 + tup2*3)
# Print minimum and maximum values of tuples
print(min(tup3))
print(max(tup4))