-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtuples_demo.py
48 lines (36 loc) · 937 Bytes
/
tuples_demo.py
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
43
44
45
46
47
48
tuple_items = ("item1", "item2", "item3")
print(tuple_items)
print(type(tuple_items))
tuple_numbers = (1, 2, 3)
print(tuple_numbers)
print(type(tuple_numbers))
tuple_repeat = ('Combine!',) * 4
print(tuple_repeat)
print(type(tuple_repeat))
mixed_tuple = ("A", 1, ("A", 1))
print(mixed_tuple)
print(type(mixed_tuple))
tuple_combined = tuple_items + tuple_numbers
print(tuple_combined)
print(type(tuple_combined))
item1, item2, item3 = tuple_items
print(item1)
print(item2)
print(item3)
print("item2" in tuple_items)
print("item3" in tuple_items)
print("item4" in tuple_items)
print(tuple_items.index("item2"))
tuple_items = ("item1", "item2", "item3")
print(tuple_items[0])
print(tuple_items[1])
print(tuple_items[2])
print(len(tuple_items))
print(tuple_items[-1])
print(tuple_items[-2])
print(tuple_items[0:2])
print(tuple_items[:2])
print(tuple_items[-3:-1])
string1 = "I am a string!"
print(string1[0:4])
print(string1[:-1])