-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtuple.py
More file actions
26 lines (26 loc) · 694 Bytes
/
tuple.py
File metadata and controls
26 lines (26 loc) · 694 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
# >>> point = (2.0,3.0)
# >>> point[0] = 1
# Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
# TypeError: 'tuple' object does not support item assignment
# >>> point_3d = point + (4.0,)
# >>> point_3d
# (2.0, 3.0, 4.0)
# >>> x,y,z = point_3d
# >>> x
# 2.0
# >>> y
# 3.0
# >>> z
# 4.0
# >>> print("My name is: %s %s" % ("First","Last")
# ... )
# My name is: First Last
#Tuple should have a comma seperator
tuplelist = (99.9, 100.1, 1.1)
print(tuplelist) #o/p -> (99.9, 100.1, 1.1)
tuplelist_add1 = tuplelist + (2.7,)
print(tuplelist_add1) #o/p -> (99.9, 100.1, 1.1, 2.7)
#common usage
employee = ('ID1109','William Henry', 34, "Security Specialist")
print(employee[1])