Chúc mừng!

Nhập môn Python dành cho Developer

Jasmin Ludolf

Senior Data Science Content Developer

Tổng kết Chương 1

# Define quantity
quantity = 10

# Single quotes ingredient_name = 'pasta'
# Double quotes also work ingredient_name = "pasta"
Nhập môn Python dành cho Developer

Tổng kết Chương 2

ingredient_name = "Basil Leaves"


# Convert to lowercase ingredient_name = ingredient_name.lower()
# List of ingredients
ingredients = ["pasta", "tomatoes", "garlic",
               "basil", "olive oil", "salt"]

# Get the value at the first index ingredients[0]
# Creating a dictionary
recipe_dict = {"pasta": 500,
               "tomatoes": 400, 
               "garlic": 15,
               "basil": 20, 
               "olive oil": 30,
               "salt": 5}
# Create a set
ingredients_set = {"pasta", "tomatoes", "pasta", 
                   "basil", "garlic", "olive oil",
                   "salt"}

# Create a tuple serving_sizes = (1, 2, 4, 6, 8)
Nhập môn Python dành cho Developer

Tổng kết Chương 3

Toán tử Chức năng
== Bằng
!= Khác
> Lớn hơn
>= Lớn hơn hoặc bằng
< Nhỏ hơn
<= Nhỏ hơn hoặc bằng
Từ khóa Chức năng Dùng khi
if Khi điều kiện đúng Bước đầu
elif Nếu không, kiểm tra điều kiện Sau if
else Nếu không, thực hiện hành động Sau elif
Nhập môn Python dành cho Developer

Tổng kết Chương 3

# Ingredients list
ingredients = ["pasta", "tomatoes", "garlic", "basil", "olive oil", "salt"]


# Loop through and print each ingredient for ingredient in ingredients:
print(ingredient)
pasta
tomatoes
garlic
basil
olive oil
salt
Nhập môn Python dành cho Developer

Tổng kết Chương 3

ingredients_to_add = 5
items_added = 0

while items_added < ingredients_to_add:
    items_added += 1
    remaining = ingredients_to_add - items_added

    if remaining > 3:
        print("Còn nhiều nguyên liệu")
    elif remaining >= 1:
        print("Sắp xong!")
    else:
        print("Danh sách mua sắm đã hoàn tất!")
Nhập môn Python dành cho Developer

Tổng kết Chương 3

Từ khóa Chức năng
and Kiểm tra nhiều điều kiện cùng đúng
or Kiểm tra có ít nhất một điều kiện đúng
in Kiểm tra giá trị có trong cấu trúc dữ liệu
not Kiểm tra giá trị không có trong cấu trúc dữ liệu

 

  • list.append()
Nhập môn Python dành cho Developer

Bước tiếp theo

  • Hàm dựng sẵn bổ sung

    • zip()
    • enumerate()
  • Gói và mô-đun

    • os
    • time
    • venv
    • pandas
    • requests
    • numpy
  • Xây dựng hàm tùy chỉnh

$$

  • Khóa học Intermediate Python for Developers trên DataCamp
Nhập môn Python dành cho Developer

Chúc mừng!

Nhập môn Python dành cho Developer

Preparing Video For Download...