Cấp độ: beginner30 phútminMiễn phíFreeJunior BuilderJunior Builder

CSS: Làm đẹp trang webCSS: Style your web page

Trang HTML đã được tạo kiểu với CSSA styled HTML page with CSS

Bạn sẽ học gìWhat you will learn

  • Hiểu selector, property, valueUnderstand selector, property, value
  • Thay đổi màu sắc và fontChange colors and fonts
  • Dùng margin, padding, borderUse margin, padding, border

Bạn sẽ tạo gìWhat you will build

Trang HTML đã được tạo kiểu với CSSA styled HTML page with CSS

Nội dung bài họcLesson content

Python là gì?What is Python?

Python là ngôn ngữ lập trình văn bản (text-based) phổ biến nhất thế giới. Cú pháp đơn giản, dễ đọc, gần với tiếng Anh. Python dùng trong AI, web, game, khoa học dữ liệu. Bạn có thể chạy Python online tại replit.com hoặc cài trên máy.Python is the world's most popular text-based programming language. Its syntax is simple, readable, and close to English. Python is used in AI, web, games, and data science. You can run Python online at replit.com or install it locally.

Lệnh print()The print() command

Lệnh print() hiển thị chữ lên màn hình. Chữ muốn hiển thị đặt trong ngoặc đơn và dấu nháy. Ví dụ: print("Xin chào!") sẽ in ra "Xin chào!". Bạn có thể in nhiều dòng bằng nhiều lệnh print.The print() command displays text on the screen. The text to display goes inside parentheses and quotes. For example: print("Hello!") prints "Hello!". You can print multiple lines with multiple print statements.

python
                      
                        print("Xin chào!")
print("Tôi đang học Python")
print("Hello!")
print("I am learning Python")
                      
                    

Biến trong PythonVariables in Python

Biến trong Python không cần khai báo trước. Gán giá trị trực tiếp: tên = "An", tuổi = 22. Dùng print() để hiển thị: print(tên). Có thể đổi giá trị: tuổi = 23. Python tự hiểu kiểu dữ liệu (chuỗi, số).Variables in Python do not need to be declared in advance. Assign directly: name = "An", age = 22. Use print() to display: print(name). You can change the value: age = 23. Python automatically understands the data type (string, number).

python
                      
                        ten = "An"
tuoi = 22
print("Tôi tên là", ten)
print("Tôi", tuoi, "tuổi")

# Đổi giá trị
tuoi = 23
print("Năm sau tôi", tuoi, "tuổi")
                      
                    

Kiểu dữ liệu cơ bảnBasic data types

Python có 3 kiểu cơ bản: (1) String (chuỗi) — chữ trong nháy, ví dụ "hello". (2) Integer (số nguyên) — số không có dấu chấm, ví dụ 22. (3) Float (số thập phân) — số có dấu chấm, ví dụ 22.5. Dùng type() để kiểm tra kiểu.Python has 3 basic types: (1) String — text in quotes, e.g. "hello". (2) Integer — whole numbers, e.g. 22. (3) Float — decimal numbers, e.g. 22.5. Use type() to check the type.

python
                      
                        ten = "An"          # string (str)
tuoi = 22           # integer (int)
cannang = 65.5      # float
print(type(ten))    # <class 'str'>
print(type(tuoi))   # <class 'int'>
print(type(cannang))# <class 'float'>
                      
                    

Bài tập thực hànhHands-on exercises

1Viết chương trình Python: tạo biến tên, tuổi, thành phố. In ra câu "Tôi tên [tên], [tuổi] tuổi, ở [thành phố]".Write a Python program: create variables for name, age, city. Print "My name is [name], I am [age] years old, I live in [city]".

Gợi ýHint

Dùng print() với nhiều biến cách nhau bởi dấu phẩy.Use print() with multiple variables separated by commas.

Lời giảiSolution
python
                      
                        ten = "An"
tuoi = 22
thanh_pho = "Hà Nội"
print("Tôi tên", ten, ",", tuoi, "tuổi, ở", thanh_pho)
                      
                    

2Tính tổng 2 số và in kết quả. Tạo biến a = 15, b = 27, tong = a + b. In "Tổng là [tong]".Calculate the sum of 2 numbers and print the result. Create a = 15, b = 27, total = a + b. Print "The sum is [total]".

Gợi ýHint

Dùng dấu + để cộng số. Dùng f-string hoặc dấu phẩy để ghép chữ và biến.Use + to add numbers. Use f-string or commas to combine text and variables.

Lời giảiSolution
python
                      
                        a = 15
b = 27
tong = a + b
print(f"Tổng là {tong}")
# Hoặc: print("Tổng là", tong)
                      
                    

Kiểm traQuiz

Chọn đáp án đúng cho mỗi câu. Nhấn để xem giải thích.Choose the correct answer for each question. Click to see explanation.

Câu 1: Lệnh nào in chữ lên màn hình trong Python?Q1: Which command prints text to the screen in Python?

Câu 2: Kiểu dữ liệu "hello" (trong nháy) là gì?Q2: What data type is "hello" (in quotes)?

Câu 3: Đâu là cú pháp đúng để tạo biến trong Python?Q3: Which is the correct syntax to create a variable in Python?

Câu 4: Lệnh type(22) trả về gì?Q4: What does type(22) return?

Code mẫuSample code

css
                body {
  font-family: 'Segoe UI', sans-serif;
  background: #F7FAFC;
  color: #102A43;
  max-width: 800px;
  margin: 0 auto;
  padding: 24px;
}

h1 {
  color: #00A8CC;
  border-bottom: 3px solid #FFC857;
  padding-bottom: 8px;
}