Hướng dẫn what are the numerical data types in python? - các kiểu dữ liệu số trong python là gì?
Các loại dữ liệu là phân loại hoặc phân loại các mục dữ liệu. Nó đại diện cho loại giá trị cho biết những hoạt động có thể được thực hiện trên một dữ liệu cụ thể. Vì mọi thứ là một đối tượng trong lập trình Python, các loại dữ liệu thực sự là các lớp và biến là ví dụ (đối tượng) của các lớp này. Show
Sau đây là loại dữ liệu tiêu chuẩn hoặc tích hợp của Python:
SốLoại trình tự
Trong Python, loại dữ liệu số đại diện cho dữ liệu có giá trị số. Giá trị số có thể là số nguyên, số nổi hoặc thậm chí các số phức tạp. Các giá trị này được định nghĩa là String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek6 function is used to determine the type of data type. Python3Số nguyên - Giá trị này được biểu thị bằng lớp Int. Nó chứa các số toàn bộ dương hoặc âm (không có phân số hoặc thập phân). Trong Python, không có giới hạn về giá trị số nguyên có thể là bao lâu. Initial String: GeeksForGeeks First character of String is: G Last character of String is: s0 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s1 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s2 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s3 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s4 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s5 Float - Giá trị này được biểu thị bằng lớp float. Đó là một con số thực với biểu diễn điểm nổi. Nó được chỉ định bởi một điểm thập phân. Tùy chọn, ký tự E hoặc E theo sau là số nguyên dương hoặc âm có thể được thêm vào để chỉ định ký hiệu khoa học. Initial String: GeeksForGeeks First character of String is: G Last character of String is: s0 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s1 Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]1 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s3 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s4 Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]4 Số phức - Số phức được thể hiện bằng lớp phức tạp. Nó được chỉ định là (phần thực) + (phần tưởng tượng) j. Ví dụ: 2+3J Lưu ý - Hàm String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek6 được sử dụng để xác định loại loại dữ liệu. Output: Type of a: Loại trình tựBoolean
Số nguyên - Giá trị này được biểu thị bằng lớp Int. Nó chứa các số toàn bộ dương hoặc âm (không có phân số hoặc thập phân). Trong Python, không có giới hạn về giá trị số nguyên có thể là bao lâu.Float - Giá trị này được biểu thị bằng lớp float. Đó là một con số thực với biểu diễn điểm nổi. Nó được chỉ định bởi một điểm thập phân. Tùy chọn, ký tự E hoặc E theo sau là số nguyên dương hoặc âm có thể được thêm vào để chỉ định ký hiệu khoa học. Số phức - Số phức được thể hiện bằng lớp phức tạp. Nó được chỉ định là (phần thực) + (phần tưởng tượng) j. Ví dụ: 2+3JLưu ý - Hàm String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek6 được sử dụng để xác định loại loại dữ liệu. Python3String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek7 String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek8 String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek9 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s0 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s1 Initial empty Tuple: () Tuple with the use of String: ('Geeks', 'For') Tuple using List: (1, 2, 4, 5, 6) Tuple with the use of function: ('G', 'e', 'e', 'k', 's') Tuple with nested tuples: ((0, 1, 2, 3), ('python', 'geek'))2 Initial empty Tuple: () Tuple with the use of String: ('Geeks', 'For') Tuple using List: (1, 2, 4, 5, 6) Tuple with the use of function: ('G', 'e', 'e', 'k', 's') Tuple with nested tuples: ((0, 1, 2, 3), ('python', 'geek'))3 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s0 Initial empty Tuple: () Tuple with the use of String: ('Geeks', 'For') Tuple using List: (1, 2, 4, 5, 6) Tuple with the use of function: ('G', 'e', 'e', 'k', 's') Tuple with nested tuples: ((0, 1, 2, 3), ('python', 'geek'))5 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s6 String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek8 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s8 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s0 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s1 First element of tuple 1 Last element of tuple 5 Third last element of tuple 31 Initial empty Tuple: () Tuple with the use of String: ('Geeks', 'For') Tuple using List: (1, 2, 4, 5, 6) Tuple with the use of function: ('G', 'e', 'e', 'k', 's') Tuple with nested tuples: ((0, 1, 2, 3), ('python', 'geek'))3 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s0 Initial empty Tuple: () Tuple with the use of String: ('Geeks', 'For') Tuple using List: (1, 2, 4, 5, 6) Tuple with the use of function: ('G', 'e', 'e', 'k', 's') Tuple with nested tuples: ((0, 1, 2, 3), ('python', 'geek'))5 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s0 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s1 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s4 First element of tuple 1 Last element of tuple 5 Third last element of tuple 38 Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks7 String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek8 Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]5 String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek8 Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]7 Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]8 Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]9 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s0 Initial empty Tuple: () Tuple with the use of String: ('Geeks', 'For') Tuple using List: (1, 2, 4, 5, 6) Tuple with the use of function: ('G', 'e', 'e', 'k', 's') Tuple with nested tuples: ((0, 1, 2, 3), ('python', 'geek'))5 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s0 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s1 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s4 First element of tuple 1 Last element of tuple 5 Third last element of tuple 38 Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks7 String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek8 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s0 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s1 Traceback (most recent call last): File "/home/7e8862763fb66153d70824099d4f5fb7.py", line 8, in print(type(true)) NameError: name 'true' is not defined5 Initial empty Tuple: () Tuple with the use of String: ('Geeks', 'For') Tuple using List: (1, 2, 4, 5, 6) Tuple with the use of function: ('G', 'e', 'e', 'k', 's') Tuple with nested tuples: ((0, 1, 2, 3), ('python', 'geek'))3 Initial String: GeeksForGeeks First character of String is: G Last character of String is: s0 Initial empty Tuple: () Tuple with the use of String: ('Geeks', 'For') Tuple using List: (1, 2, 4, 5, 6) Tuple with the use of function: ('G', 'e', 'e', 'k', 's') Tuple with nested tuples: ((0, 1, 2, 3), ('python', 'geek'))5 Output: String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek
|