Hướng dẫn matplotlib cheat sheet pdf - matplotlib cheat sheet pdf
Ngày đăng:
25/10/2022
Trả lời:
0
Lượt xem:
51
Show Nội dung chính ShowShow
Cheatsheets [pdf] Handouts¶Beginner [pdf] Intermediate [pdf] Tips [pdf] Contribute¶Biến – Variables Chuỗi – Strings Biến – VariablesChuỗ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 – StringsToá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 – ArithmeticToá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 OperatorsKiể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 AlgebraKiể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 – DictionariesDanh 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 – ListVò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Điều kiện – Conditionals # prints "h\ni\n" 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 – ConditionalsBao 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 – ComprehensionsCheatsheets [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]
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é. |