-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollection.py
More file actions
85 lines (55 loc) · 1.66 KB
/
Collection.py
File metadata and controls
85 lines (55 loc) · 1.66 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#collection = single "variable" used to store multiple values
#List = [] ordered and changeable. Duplicates OK
#Set = {} unordered and immutable, but Add/Remove OK. No Duplicates
#Turple = () ordered and unchangeable. Duplicated OK. FASTER!
#Collections
#LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST
#fruits = ["Apple", "Orange", "Banana", "Coconut"] #List
#print(dir(fruits))
#print(help(fruits))
#print(len(fruits))
#print("Apple" in fruits)
#print(fruit[0])
#for fruit in fruits:
# print(fruit)
#fruits[0] = "Pineapple" #Change Value
#for fruit in fruits:
# print(fruit)
#Append an element +
#fruits.append("Pineapple")
#Remove an element -
#fruits.remove("Apple")
#Insert
#fruits.insert(0,"Pineapple")
#Sort
#fruits.sort()
#Reverse
#fruits.reverse()
#Clear
#fruits.clear()
#Index
#print(fruits.index("Apple"))
#Count
#print(fruits.count("Banana"))
#print(fruits)
#SET SET SET SET SET SET SET SET SET SET SET SET SET SET SET SET SET SET SET
#fruits = {"Apple", "Orange", "Banana", "Coconut"} #Set
#print(dir(fruits))
#print(help(fruits))
#print(len(fruits))
#print("Apple" in fruits)
#fruits.add("Pineapple")
#fruits.remove("Orange")
#fruits.pop() #Will remove the first element in the set
#fruits.clear()
#print(fruits)
#TUPPLE TUPPLE TUPPLE TUPPLE TUPPLE TUPPLE TUPPLE TUPPLE TUPPLE TUPPLE TUPPLE
fruits = ("Apple", "Orange", "Banana", "Coconut") #Tuple
#print(dir(fruits))
#print(help(fruits))
#print(len(fruits))
#print("Apple" in fruits)
#print(fruits.index("Apple"))
print(fruits.count("Coconut"))
for fruit in fruits:
print(fruit)