Bài viết này dành cho những người đã có kinh nghiệm lập trình và muốn học nhanh Python
Tôi đã tạo tài nguyên này vì thất vọng khi không thể tìm thấy khóa học trực tuyến hoặc bất kỳ tài nguyên nào khác dạy Python cho các lập trình viên đã biết các ngôn ngữ lập trình khác
Trong khóa học này, tôi sẽ trình bày tất cả những kiến thức cơ bản về Python [các bài học chuyên sâu sẽ được bổ sung sau] để bạn có thể bắt đầu làm quen với ngôn ngữ này một cách nhanh chóng
Mục lục
- Thiết lập môi trường
- Chào thế giới
- Dây
- Số
- Trôi nổi
- bool
- Danh sách
- Tuple
- bộ
- Từ điển
- nếu. khác
- vòng lặp
- Chức năng
- Các lớp học
- mô-đun
- Giá trị thật và giả
- xử lý ngoại lệ
Thiết lập môi trường
Để bắt đầu, hãy cài đặt Python 3. Tôi khuyên bạn nên sử dụng VSCode làm trình chỉnh sửa của mình. Nó có rất nhiều tiện ích mở rộng để định cấu hình để bạn có thể thiết lập môi trường của mình chỉ trong vài phút
Chào thế giới
print["Hello world"]
Nếu bạn đã biết cơ bản về lập trình, có thể bạn sẽ biết cách chạy chương trình này. P. Lưu chương trình với phần mở rộng
# This is comment in Python
msg_from_computer = "Hello" # String
another_msg ='Hello in single quote' # This is also a String.
print[msg_from_computer + " World..!"]
# Type will return the data type.
print[type[msg_from_computer]] # . We will see the explanation of this later.
8. Sau đó chạy # This is comment in Python
msg_from_computer = "Hello" # String
another_msg ='Hello in single quote' # This is also a String.
print[msg_from_computer + " World..!"]
# Type will return the data type.
print[type[msg_from_computer]] # . We will see the explanation of this later.
9 hoặc 2
2 * 3
2 ** 7
[2 + 3] * 4
0Trong toàn bộ hướng dẫn này, chúng ta sẽ làm theo
2
2 * 3
2 ** 7
[2 + 3] * 4
1. 2
2 * 3
2 ** 7
[2 + 3] * 4
2 sẽ ngừng hoạt động vào năm 2020. Vì vậy, tôi nghĩ thật tốt khi sử dụng phiên bản mới nhấtBiến và kiểu dữ liệu
Các biến có thể chứa các chữ cái, số và dấu gạch dưới
Dây
# This is comment in Python
msg_from_computer = "Hello" # String
another_msg ='Hello in single quote' # This is also a String.
print[msg_from_computer + " World..!"]
# Type will return the data type.
print[type[msg_from_computer]] # . We will see the explanation of this later.
Số
2
2 * 3
2 ** 7
[2 + 3] * 4
phao nổi
________số 8Hãy cẩn thận trong nối
count = 5
print["I need" + count + "chocolates"] # This line will throw error. As count is a integer, you have to type cast it.
print["I need" + str[count] + "chocolates"] # This will work
bool
# This is comment in Python
msg_from_computer = "Hello" # String
another_msg ='Hello in single quote' # This is also a String.
print[msg_from_computer + " World..!"]
# Type will return the data type.
print[type[msg_from_computer]] # . We will see the explanation of this later.
0Danh sách
Danh sách về cơ bản giống như mảng. Trong thế giới Python, họ gọi chúng là
2
2 * 3
2 ** 7
[2 + 3] * 4
3. Và họ được lệnh# This is comment in Python
msg_from_computer = "Hello" # String
another_msg ='Hello in single quote' # This is also a String.
print[msg_from_computer + " World..!"]
# Type will return the data type.
print[type[msg_from_computer]] # . We will see the explanation of this later.
2bộ dữ liệu
Bộ dữ liệu giống như danh sách nhưng chúng không thay đổi. Điều này có nghĩa là bạn không thể thêm hoặc cập nhật chúng. Bạn chỉ có thể đọc các yếu tố. Và hãy nhớ rằng, giống như danh sách, Tuples cũng tuần tự
# This is comment in Python
msg_from_computer = "Hello" # String
another_msg ='Hello in single quote' # This is also a String.
print[msg_from_computer + " World..!"]
# Type will return the data type.
print[type[msg_from_computer]] # . We will see the explanation of this later.
3bộ
Bộ là bộ sưu tập không có thứ tự không có phần tử trùng lặp
# This is comment in Python
msg_from_computer = "Hello" # String
another_msg ='Hello in single quote' # This is also a String.
print[msg_from_computer + " World..!"]
# Type will return the data type.
print[type[msg_from_computer]] # . We will see the explanation of this later.
4từ điển
Từ điển là bản đồ khóa-giá trị trong Python. Chúng không có thứ tự
# This is comment in Python
msg_from_computer = "Hello" # String
another_msg ='Hello in single quote' # This is also a String.
print[msg_from_computer + " World..!"]
# Type will return the data type.
print[type[msg_from_computer]] # . We will see the explanation of this later.
5nếu. khác
Bạn có thể đã biết cách hoạt động của câu lệnh
2
2 * 3
2 ** 7
[2 + 3] * 4
4. Nhưng hãy xem một ví dụ ở đây# This is comment in Python
msg_from_computer = "Hello" # String
another_msg ='Hello in single quote' # This is also a String.
print[msg_from_computer + " World..!"]
# Type will return the data type.
print[type[msg_from_computer]] # . We will see the explanation of this later.
0vòng lặp
Python có hai loại vòng lặp
- Vì
- Trong khi
vòng lặp while
# This is comment in Python
msg_from_computer = "Hello" # String
another_msg ='Hello in single quote' # This is also a String.
print[msg_from_computer + " World..!"]
# Type will return the data type.
print[type[msg_from_computer]] # . We will see the explanation of this later.
1Đối với vòng lặp
# This is comment in Python
msg_from_computer = "Hello" # String
another_msg ='Hello in single quote' # This is also a String.
print[msg_from_computer + " World..!"]
# Type will return the data type.
print[type[msg_from_computer]] # . We will see the explanation of this later.
2Chức năng
# This is comment in Python
msg_from_computer = "Hello" # String
another_msg ='Hello in single quote' # This is also a String.
print[msg_from_computer + " World..!"]
# Type will return the data type.
print[type[msg_from_computer]] # . We will see the explanation of this later.
3Các lớp học
# This is comment in Python
msg_from_computer = "Hello" # String
another_msg ='Hello in single quote' # This is also a String.
print[msg_from_computer + " World..!"]
# Type will return the data type.
print[type[msg_from_computer]] # . We will see the explanation of this later.
4mô-đun
# This is comment in Python
msg_from_computer = "Hello" # String
another_msg ='Hello in single quote' # This is also a String.
print[msg_from_computer + " World..!"]
# Type will return the data type.
print[type[msg_from_computer]] # . We will see the explanation of this later.
5Giá trị thật và giả
# This is comment in Python
msg_from_computer = "Hello" # String
another_msg ='Hello in single quote' # This is also a String.
print[msg_from_computer + " World..!"]
# Type will return the data type.
print[type[msg_from_computer]] # . We will see the explanation of this later.
6xử lý ngoại lệ
# This is comment in Python
msg_from_computer = "Hello" # String
another_msg ='Hello in single quote' # This is also a String.
print[msg_from_computer + " World..!"]
# Type will return the data type.
print[type[msg_from_computer]] # . We will see the explanation of this later.
7Cảm ơn bạn đã đọc. ]
Được đăng ban đầu trong repo Github này. Khóa học Python
QUẢNG CÁO
QUẢNG CÁO
QUẢNG CÁO
QUẢNG CÁO
QUẢNG CÁO
QUẢNG CÁO
QUẢNG CÁO
QUẢNG CÁO
QUẢNG CÁO
QUẢNG CÁO
QUẢNG CÁO
QUẢNG CÁO
QUẢNG CÁO
QUẢNG CÁO
Sản xuất tại Ấn Độ, Kỹ sư phần mềm, Trình tạo sê-ri, Rails ❤️ JavaScript
Nếu bạn đọc đến đây, hãy tweet cho tác giả để cho họ thấy bạn quan tâm. Tweet một lời cảm ơn
Học cách viết mã miễn phí. Chương trình giảng dạy mã nguồn mở của freeCodeCamp đã giúp hơn 40.000 người có được việc làm với tư cách là nhà phát triển. Bắt đầu