
Xem Tắt
Matplotlib cheatsheets and handouts¶
Nội dung chính
Bạn Đang Xem: Hướng dẫn python cheat sheet datacamp – Python cheat sheet datacamp
Nội dung chính
Bạn Đang Xem: Hướng dẫn python cheat sheet datacamp – Python cheat sheet datacamp
- Matplotlib cheatsheets and handouts¶
- Contribute¶
- Biến – Variables
- Chuỗi – Strings
- Toán tử số học – Arithmetic
- Toán tử quan hệ – Relational Operators
- Kiểu dữ liệu Boolean – Boolean Algebra
- Kiểu dữ liệu từ điển – Dictionaries
- Danh sách – List
- Vòng lặp – Loops
- Điều kiện – Conditionals
- Bao hàm – Comprehensions
- Matplotlib cheatsheets and handouts¶
- Contribute¶
- Biến – Variables
- Chuỗi – Strings
- Toán tử số học – Arithmetic
- Toán tử quan hệ – Relational Operators
- Kiểu dữ liệu Boolean – Boolean Algebra
- Kiểu dữ liệu từ điển – Dictionaries
- Danh sách – List
- Vòng lặp – Loops
- Điều kiện – Conditionals
- Bao hàm – Comprehensions
Nội dung chính
Bạn Đang Xem: Hướng dẫn python cheat sheet datacamp – Python cheat sheet datacamp
- Matplotlib cheatsheets and handouts¶
- Contribute¶
- Biến – Variables
- Chuỗi – Strings
- Toán tử số học – Arithmetic
- Toán tử quan hệ – Relational Operators
- Kiểu dữ liệu Boolean – Boolean Algebra
- Kiểu dữ liệu từ điển – Dictionaries
- Danh sách – List
- Vòng lặp – Loops
- Điều kiện – Conditionals
- Bao hàm – Comprehensions
Cheatsheets [pdf]
Handouts¶
Beginner [pdf]
Intermediate [pdf]
Tips [pdf]
Contribute¶
Biến – Variables
Xem Thêm : 8 biểu đồ phân bố mật độ tốt nhất, đừng bỏ lỡ
Chuỗi – Strings
Biến – Variables
Xem Thêm : 8 biểu đồ phân bố mật độ tốt nhất, đừng bỏ lỡ
Chuỗi – Strings
num = 11 # hiển thị 11 word = "Hello" # hiển thị "Hello" logic = True # hiển thị True my_list = [2, 3, 4] # hiển thị [2, 3, 4] my_tuple = (5, 2) # hiển thị (5, 2) my_dict = {} # hiển thị {} my_set = {4, 5} # hiển thị {4, 5}
Chuỗi – Strings
Toán tử số học – Arithmetic
name = "Jeremy" # hiển thị "Jeremy" size = len(name) # hiển thị độ dài 6 ký tự của chuỗi twice = name * 2 # hiển thị "JeremyJeremy" concat = name + "'s" # hiển thị "Jeremy's" check = "e" in name # hiển thị True first = name[0] # hiển thị "J" last = name[-1] # hiển thị "y" subset = name[1:4] # hiển thị "ere" lower = name.lower() # hiển thị "jeremy" upper = name.upper() # hiển thị "JEREMY"
Toán tử số học – Arithmetic
Toán tử quan hệ – Relational Operators
add = 3 + 7 # hiển thị tổng là 10 sub = 5 - 3 # hiển thị hiệu là 2 mul = 3 * 3 # hiển thị tích là 9 div = 5 / 2 # hiển thị thương là of 2.5 idiv = 5 // 2 # hiển thị kết quả là 2 exp = 2 ** 4 # hiển thị 16 rem = 7 % 2 # hiển thị 1 paren = (3 + 2) / 5 # hiển thị 1.0
Toán tử quan hệ – Relational Operators
Kiểu dữ liệu Boolean – Boolean Algebra
less = 2 < 4 # hiển thị True less_equals = 3 <= 3 # hiển thị True equals = 4 == 7 # hiển thị False greater_equals = 5 >= 2 # hiển thị True greater = -4 > 5 # hiển thị False
Kiểu dữ liệu Boolean – Boolean Algebra
Kiểu dữ liệu từ điển – Dictionaries
is_cold = True # hiển thị True is_wet = True # hiển thị True is_not_cold = not is_cold # hiển thị False am_sad = is_cold and is_wet # hiển thị True am_mad = is_cold or is_wet # hiển thị True
Kiểu dữ liệu từ điển – Dictionaries
Danh sách – List
my_map = {"x": 2} # hiển thị {"x": 2} value = my_map["x"] # hiển thị 2 my_map["y"] = 5 # adds "y": 5 to dict list(my_map.keys()) # trả về [x, y] list(my_map.values()) # trả về [2, 5]
Danh sách – List
Vòng lặp – Loops
items = [1, 2, 3] # hiển thị [1, 2, 3] length = len(items) # hiển thị 3 begin = items[0] # hiển thị 1 end = items[-1] # hiển thị 3 section = items[0:1] # hiển thị [1] exists = 2 in items # hiển thị True items.append(4) # adds 4 to end of list items.extend([5, 6]) # appends 5 and 6 items.reverse() # đảo ngược thứ tự của list items.clear() # làm trống list
Vòng lặp – Loops
Xem Thêm : Cách khắc phục lỗi Messenger không hiện bong bóng chat cực hiệu quả 88
Điều kiện – Conditionals
# prints "hnin" greet = "hi" index = 0 while index < len(greet): print(greet[index]) index += 1 #cùng code, nhưng lặp for for index in range(len(greet)): print(greet[index]) #cùng code, nhưng lặp for each for char in greet: print(char)
Điều kiện – Conditionals
Bao hàm – Comprehensions
# prints "Nice car!" cars = ["Tesla", "Ford", "Toyota"] if "Toyota" in cars: print("Nice car!") elif "Audi" in cars: print("Not bad!") else: print("Mistakes were made.")
Cheatsheets [pdf]
# removes "Toyota" from cars # prints "We won't be needing that!" if "Toyota" in cars: if "Tesla" in cars: cars.remove("Toyota") print("We won't be needing that!"
Bao hàm – Comprehensions
Cheatsheets [pdf]
name = "Jeremy" # hiển thị "Jeremy" size = len(name) # hiển thị độ dài 6 ký tự của chuỗi twice = name * 2 # hiển thị "JeremyJeremy" concat = name + "'s" # hiển thị "Jeremy's" check = "e" in name # hiển thị True first = name[0] # hiển thị "J" last = name[-1] # hiển thị "y" subset = name[1:4] # hiển thị "ere" lower = name.lower() # hiển thị "jeremy" upper = name.upper() # hiển thị "JEREMY"
0
Handouts¶
Beginner [pdf]
- Intermediate [pdf]
- Tips [pdf]
- Issues, suggestions, or pull-requests gratefully accepted at matplotlib/cheatsheets
Một bài viết ngắn tổng hợp các lệnh Python cơ bản nhất cho lập trình viên mới bắt đầu với Python. Cùng TopDev xem qua và lưu về cheatsheet Python này nhé.
Nguồn: https://quatangtiny.com
Danh mục: Blog