Please enable JavaScript.
Coggle requires JavaScript to display documents.
Programming (Method and Library) - Coggle Diagram
Programming (Method and Library)
Data Strcuture (Python)
Lists(In other language we called array) : ยืดหยุ่น เก็บได้หลายค่า ไม่ Fix size
Tuple :can not delete , add data , replace element
Set : ไม่สามารถเก็บค่าซ้ำได้
List Method
append > add to the end of the list
count > return number of times was found
extend > take new list and add into the old list
index > return the first index where is found
pop > remove and return the last element
remove > remove element
reverse > sort from the last to the first
sort > sort element from low to high
Tuple method (ไม่มี method เฉพาะของตัวเอง)
Set Method
union > contains all the elements from both set
intersaction > contains the elements that appear in both sets
difference > contains the elements in set1 but not in set2
symmetric_difference > หาค่าที่ไม่ซ้ำกันใน both set
Math module
ceil : ปัดเศษขึ้น 1 จำนวนเต็ม(whatever)
floor : ปัดเศษลง 1 จำนวนเต็ม(Whatever)
sqrt : หาค่าแสวค์ที่2
Random Moduel
Choice : สุ่มดึงตัวเลขหนึ่งตัวจาก List มา
randint : สุ่มค่าตัวเลขระหว่าง ค่าที่เรา Setไว้
sample : สุ่มค่าตัวเลขจาก List (จำนวนตามที่เราต้องการ)
shuffle : การสลับตำแหน่งของค่า (Similar to set when access)
Seed :
Itertools module :
Combinations : ("abcd") > (ab) (ac) (ad) (bc) (bd) (cd):
permutations ให้นึกถึงการคูณกระจาย
chain : น้ำข้อมูลมาเชื่อมต่อกัน
product : ผลคูณคาร์ทีเชียน
example. letters = ['a', 'b']
numbers = [1, 2, 3]
('a', 1)
('a', 2)
('a', 3)
('b', 1)
('b', 2)
('b', 3)
cycle : สร้างลูปไม่มีที่สิ้นสุด
Dictionary Method
keys > return a sequence of keys
values > return a sequence of values
itmes > return a sequence of tuples (key,value)
del > delete element
clear > deletes all entires
pop > removes the items for the key then return its value
Build-in function
max
number = finding the most value
string = number > Big > Small