-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtuple.py
More file actions
41 lines (27 loc) · 764 Bytes
/
Copy pathtuple.py
File metadata and controls
41 lines (27 loc) · 764 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
#Tuple Data Type/Data Structure
#Tuple is same as list, list is mutable tuple is immutable.
#immutable = unchangeable
#tuples allows duplicate values
#tuples allows heterogenious daa types
mytyuple = ("one", "two", 1, True)
print(mytyuple)
mytuple1 = ("one", "two","three","one")
print (mytuple1)
#Diff of tuples from list
#syntax
my_list = [1,2,3,4]
my_tuple = (1,2,3,4)
print (my_list)
print (my_tuple)
#mutability
my_list[2] = 10
print (my_list) # 1,2,10,4
#my_tuple[1] = 10
print(my_tuple)
print(my_list.__sizeof__())
print(my_tuple.__sizeof__())
#List and tuples are same, the only diff is list is mutable and tuple is immutable
# both are ordered, slicing, duplicate, heterogenious
my_tuple1 = (10,)
print (my_tuple1)
print (type(my_tuple1))