Python là một ngôn ngữ lập trình cấp cao, đa năng. Nó được thiết kế với sự nhấn mạnh vào khả năng đọc mã và cú pháp của nó cho phép các lập trình viên thể hiện các khái niệm của chúng trong ít dòng mã hơn và các mã này được gọi là tập lệnh. Các tập lệnh này chứa các bộ ký tự, mã thông báo và số nhận dạng. Trong bài viết này, chúng tôi sẽ tìm hiểu về các bộ ký tự, mã thông báo và định danh.
Bộ ký tự
Một bộ ký tự là một tập hợp các ký tự hợp lệ được chấp nhận bởi một ngôn ngữ lập trình trong tập lệnh. Trong trường hợp này, chúng ta đang nói về ngôn ngữ lập trình Python. Vì vậy, bộ ký tự Python là một tập hợp các ký tự hợp lệ được nhận ra bởi ngôn ngữ Python. Đây là những nhân vật chúng ta có thể sử dụng trong khi viết một tập lệnh bằng Python. Python hỗ trợ tất cả các ký tự ASCII / Unicode bao gồm:
- Bảng chữ cái: tất cả các bảng chữ cái vốn [A-Z] và nhỏ [A-Z].All capital [A-Z] and small [a-z] alphabets.All capital [A-Z] and small [a-z] alphabets.
- Chữ số: Tất cả các chữ số 0-9.All digits 0-9.All digits 0-9.
- Các biểu tượng đặc biệt: Python hỗ trợ tất cả các loại biểu tượng đặc biệt như, Hồi ‘l; :! ~ @ # $ % ^ `& * [] _ + - = {} [] \.Python supports all kind of special symbols like, ” ‘ l ; : ! ~ @ # $ % ^ ` & * [ ] _ + – = { } [ ] \ .Python supports all kind of special symbols like, ” ‘ l ; : ! ~ @ # $ % ^ ` & * [ ] _ + – = { } [ ] \ .
- Không gian trắng: Không gian trắng như không gian tab, không gian trống, đường mới và trở lại vận chuyển.White spaces like tab space, blank space, newline, and carriage return.White spaces like tab space, blank space, newline, and carriage return.
- Khác: Tất cả các ký tự ASCII và Unicode được hỗ trợ bởi Python tạo thành bộ ký tự Python.All ASCII and UNICODE characters are supported by Python that constitutes the Python character set.All ASCII and UNICODE characters are supported by Python that constitutes the Python character set.
Tokens
Mã thông báo là đơn vị cá nhân nhỏ nhất trong chương trình Python. Tất cả các tuyên bố và hướng dẫn trong một chương trình được xây dựng bằng mã thông báo. Các mã thông báo khác nhau trong Python là:
1. Từ khóa: Từ khóa là những từ có một số ý nghĩa hoặc ý nghĩa đặc biệt trong ngôn ngữ lập trình. Chúng có thể được sử dụng làm tên biến, tên chức năng hoặc bất kỳ mục đích ngẫu nhiên nào khác. Chúng được sử dụng cho các tính năng đặc biệt của chúng. Trong Python, chúng tôi có 33 từ khóa, một số trong số chúng là: cố gắng, sai, đúng, lớp, phá vỡ, tiếp tục, và, như, khẳng định, trong khi, cho, trong, tăng, ngoại trừ, hoặc, nếu, elif, in, nhập, nhập , vân vân.Keywords are words that have some special meaning or significance in a programming language. They can’t be used as variable names, function names, or any other random purpose. They are used for their special features. In Python we have 33 keywords some of them are: try, False, True, class, break, continue, and, as, assert, while, for, in, raise, except, or, not, if, elif, print, import, etc.Keywords are words that have some special meaning or significance in a programming language. They can’t be used as variable names, function names, or any other random purpose. They are used for their special features. In Python we have 33 keywords some of them are: try, False, True, class, break, continue, and, as, assert, while, for, in, raise, except, or, not, if, elif, print, import, etc.
Python3
Hello Geeks04
Hello Geeks05
Hello Geeks06
Hello Geeks4
Hello Geeks5
Hello Geeks6
Hello Geeks4
Hello Geeks8
Hello Geeks9
Hello Geeks Geeks for Geeks is a learning platform0
Hello Geeks Geeks for Geeks is a learning platform1
Hello Geeks Geeks for Geeks is a learning platform2
Hello Geeks Geeks for Geeks is a learning platform3
Hello Geeks4
Hello Geeks Geeks for Geeks is a learning platform5
Hello Geeks Geeks for Geeks is a learning platform1
Hello Geeks Geeks for Geeks is a learning platform2
Hello Geeks Geeks for Geeks is a learning platform8
Output:
Hello Geeks5
2. Định danh: Định danh là tên được đặt cho bất kỳ biến, chức năng, lớp, danh sách, phương thức, vv để nhận dạng của họ. Python là một ngôn ngữ nhạy cảm trường hợp và nó có một số quy tắc và quy định để đặt tên cho một định danh. Dưới đây là một số quy tắc để đặt tên cho một định danh:-Identifiers are the names given to any variable, function, class, list, methods, etc. for their identification. Python is a case-sensitive language and it has some rules and regulations to name an identifier. Here are some rules to name an identifier:-Identifiers are the names given to any variable, function, class, list, methods, etc. for their identification. Python is a case-sensitive language and it has some rules and regulations to name an identifier. Here are some rules to name an identifier:-
- Như đã nêu ở trên, Python nhạy cảm trường hợp. Vì vậy, trường hợp quan trọng trong việc đặt tên định danh. Và do đó các chuyên viên máy tính và chuyên viên máy tính là hai định danh khác nhau.geeks and Geeks are two different identifiers.geeks and Geeks are two different identifiers.
- Định danh bắt đầu bằng chữ hoa [A-Z], một chữ cái nhỏ [A-Z] hoặc dấu gạch dưới [_]. Nó có thể bắt đầu với bất kỳ nhân vật nào khác.
- Ngoại trừ các chữ cái và dấu gạch dưới, các chữ số cũng có thể là một phần của định danh nhưng có thể là nhân vật đầu tiên của nó.
- Bất kỳ ký tự đặc biệt hoặc khoảng trắng nào khác đều bị nghiêm cấm trong một định danh.
- Một định danh có thể là một từ khóa.
Ví dụ: một số định danh hợp lệ là GFG, GeekSforGeek, _Geek, Mega12, v.v. trong khi 91Road, #Tweet, tôi, v.v.Some valid identifiers are gfg, GeeksforGeeks, _geek, mega12, etc. While 91road, #tweet, i am, etc. are not valid identifiers.Some valid identifiers are gfg, GeeksforGeeks, _geek, mega12, etc. While 91road, #tweet, i am, etc. are not valid identifiers.
Python3
Hello Geeks Geeks for Geeks is a learning platform9
Hello Geeks70
Hello Geeks71
Hello Geeks72
Hello Geeks70
Hello Geeks74
Hello Geeks5
Hello Geeks76
Hello Geeks5
Hello Geeks78
Output:
Hello Geeks
3 Python hỗ trợ các loại nghĩa đen khác nhau như:Literals are the fixed values or data items used in a source code. Python supports different types of literals such as:Literals are the fixed values or data items used in a source code. Python supports different types of literals such as:
. Ví dụ: Khoa học máy tính của người Hồi giáo, ‘Sam, v.v ... Chúng ta cũng có thể sử dụng trích dẫn ba để viết các chuỗi nhiều dòng.The text written in single, double, or triple quotes represents the string literals in Python. For example: “Computer Science”, ‘sam’, etc. We can also use triple quotes to write multi-line strings.The text written in single, double, or triple quotes represents the string literals in Python. For example: “Computer Science”, ‘sam’, etc. We can also use triple quotes to write multi-line strings.
Python3
Hello Geeks79
Hello Geeks70
Hello Geeks71
Hello Geeks72
Hello Geeks70
Hello Geeks74
Hello Geeks35
Hello Geeks70
Hello Geeks5
Hello Geeks38
Hello Geeks5
Hello Geeks78
Hello Geeks5
Hello Geeks042
3 Python hỗ trợ các loại nghĩa đen khác nhau như:
Hello Geeks Geeks for Geeks is a learning platform
. Ví dụ: Khoa học máy tính của người Hồi giáo, ‘Sam, v.v ... Chúng ta cũng có thể sử dụng trích dẫn ba để viết các chuỗi nhiều dòng. Character literal is also a string literal type in which the character is enclosed in single or double-quotes. Character literal is also a string literal type in which the character is enclosed in single or double-quotes.
Python3
Hello Geeks79
Hello Geeks70
Hello Geeks71
Đầu ra
Hello Geeks5
Hello Geeks38
Hello Geeks5
Hello Geeks78
Output:
Hello Geeks7
.These are the literals written in form of numbers. Python supports the following numerical literals:These are the literals written in form of numbers. Python supports the following numerical literals:
Hello Geeks
79Hello Geeks
70Hello Geeks
045 It includes both positive and negative numbers along with 0. It doesn’t include fractional parts. It can also include binary, decimal, octal, hexadecimal literal. It includes both positive and negative numbers along with 0. It doesn’t include fractional parts. It can also include binary, decimal, octal, hexadecimal literal.Hello Geeks
72Hello Geeks
70Hello Geeks
048It includes both positive and negative real numbers. It also includes fractional parts.It includes both positive and negative real numbers. It also includes fractional parts.- [iii] Biết chữ số: Đây là những chữ viết dưới dạng số. Python hỗ trợ các chữ số sau: It includes a+bi numeral, here a represents the real part and b represents the complex part. It includes a+bi numeral, here a represents the real part and b represents the complex part.
Python3
Số nguyên theo nghĩa đen: Nó bao gồm cả số dương và số âm cùng với 0. Nó không bao gồm các phần phân số. Nó cũng có thể bao gồm nhị phân nhị phân, thập phân, bát phân, thập lục phân.
Phao chữ: Nó bao gồm cả số thực tích cực và tiêu cực. Nó cũng bao gồm các bộ phận phân số.
Phức tạp: Nó bao gồm số A+BI, ở đây A đại diện cho phần thực và B đại diện cho phần phức tạp.
Hello Geeks5
Hello Geeks38
Hello Geeks79
Hello Geeks70
Hello Geeks055
Hello Geeks5
Hello Geeks042
. Đây là đúng và sai.Boolean literals have only two values in Python. These are True and False.Boolean literals have only two values in Python. These are True and False.
Python3
Hello Geeks79
Hello Geeks70
Hello Geeks121
Hello Geeks72
Hello Geeks70
Hello Geeks124
Hello Geeks7030
Hello Geeks121
Hello Geeks128
Hello Geeks35
Hello Geeks70
Hello Geeks161
Hello Geeks162
Hello Geeks163
Hello Geeks5
Hello Geeks165
. Nó được sử dụng để biểu thị không có gì, không có giá trị hoặc không có giá trị. Python has a special literal ‘None’. It is used to denote nothing, no values, or the absence of value. Python has a special literal ‘None’. It is used to denote nothing, no values, or the absence of value.
Python3
.Literals collections in python includes list, tuple, dictionary, and sets.Literals collections in python includes list, tuple, dictionary, and sets.
- Danh sách: Đây là danh sách các yếu tố được biểu thị trong dấu ngoặc vuông với dấu phẩy ở giữa. Các biến này có thể thuộc bất kỳ kiểu dữ liệu nào và cũng có thể được thay đổi.It is a list of elements represented in square brackets with commas in between. These variables can be of any data type and can be changed as well.It is a list of elements represented in square brackets with commas in between. These variables can be of any data type and can be changed as well.
- Tuple: Đây cũng là một danh sách các yếu tố hoặc giá trị được phân tách bằng dấu phẩy trong khung tròn. Các giá trị có thể thuộc bất kỳ loại dữ liệu nào nhưng có thể thay đổi.It is also a list of comma-separated elements or values in round brackets. The values can be of any data type but can’t be changed.It is also a list of comma-separated elements or values in round brackets. The values can be of any data type but can’t be changed.
- Từ điển: Đây là tập hợp các cặp khóa-giá trị không được đặt hàng.It is the unordered set of key-value pairs.It is the unordered set of key-value pairs.
- Đặt: Đó là bộ sưu tập các yếu tố không có thứ tự trong niềng răng xoăn ‘{}.It is the unordered collection of elements in curly braces ‘{}’.It is the unordered collection of elements in curly braces ‘{}’.
Python3
Hello Geeks166
Hello Geeks70
Hello Geeks168
Hello Geeks169___
Hello Geeks07
Hello Geeks70
Hello Geeks16
Hello Geeks0
Hello Geeks1____1122____11
Hello Geeks121____11____116
Hello Geeks17
Hello Geeks18
Hello Geeks70
Hello Geeks20
Hello Geeks0
Hello Geeks Geeks for Geeks is a learning platform1
Hello Geeks23
Hello Geeks1____11221
Hello Geeks27
Hello Geeks1
Hello Geeks121__21____131
Hello Geeks32
Các
Hello Geeks5
Hello Geeks45
Hello Geeks5
Hello Geeks47
Hello Geeks5
Hello Geeks49
Hello Geeks5
Hello Geeks51
Đầu ra
Hello Geeks3
.These are the literals written in form of numbers. Python supports the following numerical literals:These are the tokens responsible to perform an operation in an expression. The variables on which operation is applied are called operands. Operators can be unary or binary. Unary operators are the ones acting on a single operand like complement operator, etc. While binary operators need two operands to operate.
Python3
Hello Geeks79
Hello Geeks70
Hello Geeks045 It includes both positive and negative numbers along with 0. It doesn’t include fractional parts. It can also include binary, decimal, octal, hexadecimal literal.
5. Dấu chấm câu: Đây là những biểu tượng được sử dụng trong Python để tổ chức các cấu trúc, câu lệnh và biểu thức. Một số dấu chấm câu là: [] {} [] @ & nbsp;-= & nbsp;+= & nbsp;*= & nbsp; // = & nbsp; ** == & nbsp; =, v.v.These are the symbols that used in Python to organize the structures, statements, and expressions. Some of the Punctuators are: [ ] { } [ ] @ -= += *= //= **== = , etc.These are the symbols that used in Python to organize the structures, statements, and expressions. Some of the Punctuators are: [ ] { } [ ] @ -= += *= //= **== = , etc.
Có bao nhiêu loại mã thông báo trong Python?
Các loại mã thông báo bình thường là số nhận dạng, từ khóa, toán tử, phân định và chữ.Có năm loại mã thông báo được phép trong Python.
Là một mã thông báo vận hành python?
Các nhà khai thác là các mã thông báo đặc biệt đại diện cho các tính toán như bổ sung, nhân và chia.Các giá trị mà toán tử hoạt động được gọi là toán hạng.Các mã thông báo +, - và *, và việc sử dụng dấu ngoặc đơn để nhóm, có nghĩa là trong Python những gì chúng có nghĩa trong toán học.. The values the operator works on are called operands. The tokens + , - , and * , and the use of parentheses for grouping, mean in Python what they mean in mathematics.. The values the operator works on are called operands. The tokens + , - , and * , and the use of parentheses for grouping, mean in Python what they mean in mathematics.