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.
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ự
- Boolean
- Bộ
- Từ điển
Số
Loại trình tự
- Boolean– This value is represented by int class. It contains positive or negative whole numbers [without fraction or decimal]. In Python there is no limit to how long an integer value can be.
- Bộ– This value is represented by float class. It is a real number with floating point representation. It is specified by a decimal point. Optionally, the character e or E followed by a positive or negative integer may be appended to specify scientific notation.
- Từ điển – Complex number is represented by complex class. It is specified as [real part] + [imaginary part]j. For example – 2+3j
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 Geek
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
Creating a multiline String:
Geeks
For
Life
3, String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
Creating a multiline String:
Geeks
For
Life
4and String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
Creating a multiline String:
Geeks
For
Life
5Class trong Python. –
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life6 function is used to determine the type of data type.
Python3
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.
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 Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life6 được sử dụng để xác định loại loại dữ liệu.
Output:
Type of a: Type of b: Type of c:
Loại trình tự
Boolean
- Bộ
- Từ điển
- 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 Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life
3,String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life
4andString with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life
5Class trong Python.
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+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 Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life6 được sử dụng để xác định loại loại dữ liệu.
Python3
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life7
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life9
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 Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
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 Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
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 Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
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 Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
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 String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life
Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
1Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
2Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
3Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
4Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
5
Trong Python, trình tự là bộ sưu tập có thứ tự của các loại dữ liệu tương tự hoặc khác nhau. Trình tự cho phép lưu trữ nhiều giá trị theo kiểu có tổ chức và hiệu quả. Có một số loại trình tự trong Python -
Python3
Sợi dây
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 Set: set[] Set with the use of String: {'F', 'o', 'G', 's', 'r', 'k', 'e'} Set with the use of List: {'Geeks', 'For'} Set with the use of Mixed Values {1, 2, 4, 6, 'Geeks', 'For'}4
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
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life00
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
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life03
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life04
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life05
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
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life08
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
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life03
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life12
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life13
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life05
Output:
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s
Danh sách– To know more about strings, refer Python String.
Tuple
1] Chuỗi
Trong Python, các chuỗi là các mảng byte đại diện cho các ký tự Unicode. Một chuỗi là một tập hợp của một hoặc nhiều ký tự được đặt trong một trích dẫn, trích dẫn kép hoặc ba. Trong Python không có kiểu dữ liệu ký tự, một ký tự là một chuỗi độ dài. Nó được đại diện bởi ________ 46 class. & Nbsp;
Tạo chuỗi
Python3
Chuỗi trong Python có thể được tạo bằng cách sử dụng trích dẫn đơn hoặc trích dẫn đôi hoặc thậm chí trích dẫn ba.
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
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life21
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 String: GeeksForGeeks First character of String is: G Last character of String is: s1
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life16
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
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 Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks9
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
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life34
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 String: GeeksForGeeks First character of String is: G Last character of String is: s1
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life16
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
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 Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
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']]8
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
3
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 String: GeeksForGeeks First character of String is: G Last character of String is: s1
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life16
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life29
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life04
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life58
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
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life16
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life29
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]7
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life05
Truy cập các thành phần của chuỗi
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
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life76
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 String: GeeksForGeeks First character of String is: G Last character of String is: s1
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life16
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
Output:
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]
Trong Python, các ký tự riêng lẻ của chuỗi có thể được truy cập bằng cách sử dụng phương pháp lập chỉ mục. Lập chỉ mục cho phép tham chiếu địa chỉ âm đến các ký tự truy cập từ phía sau chuỗi, ví dụ: -1 đề cập đến nhân vật cuối cùng, -2 đề cập đến nhân vật cuối cùng thứ hai, v.v.
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 Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
Initial blank Set: set[] Set with the use of String: {'F', 'o', 'G', 's', 'r', 'k', 'e'} Set with the use of List: {'Geeks', 'For'} Set with the use of Mixed Values {1, 2, 4, 6, 'Geeks', 'For'}1
Python3
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life16
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life29
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life43
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s3
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life45
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s3
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life43__
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
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life96
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 String: GeeksForGeeks First character of String is: G Last character of String is: s1
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life16
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life29
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]7
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life05
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: s12
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 String: GeeksForGeeks First character of String is: G Last character of String is: s1
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life16
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life29
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life12
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life13
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life05
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
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life16
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life29
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life12
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s26
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life05
Output:
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks
Lưu ý - Để biết thêm về danh sách, hãy tham khảo danh sách Python.– To know more about Lists, refer Python List.
3] Tuple
Giống như danh sách, Tuple cũng là một bộ sưu tập các đối tượng Python được đặt hàng. Sự khác biệt duy nhất giữa tuple và danh sách là các bộ dữ liệu là bất biến, tức là các bộ dữ liệu không thể được sửa đổi sau khi nó được tạo ra. Nó được đại diện bởi ________ 228 Class. & Nbsp;
Tạo tuple
Trong Python, các bộ dữ liệu được tạo ra bằng cách đặt một chuỗi các giá trị được phân tách bằng ‘dấu phẩy có hoặc không sử dụng dấu ngoặc đơn để nhóm chuỗi dữ liệu. Tuples có thể chứa bất kỳ số lượng phần tử và của bất kỳ kiểu dữ liệu nào [như chuỗi, số nguyên, danh sách, v.v.].
Lưu ý: Bộ dữ liệu cũng có thể được tạo với một phần tử duy nhất, nhưng nó hơi khó khăn. Có một yếu tố trong dấu ngoặc đơn là không đủ, phải có một dấu vết dấu vết để biến nó thành một tuple. Tuples can also be created with a single element, but it is a bit tricky. Having one element in the parentheses is not sufficient, there must be a trailing ‘comma’ to make it a tuple.
Python3
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s29
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s31
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: s34
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 String: GeeksForGeeks First character of String is: G Last character of String is: s37
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s29
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s1
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life68
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s3
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life70
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 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: s47
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 String: GeeksForGeeks First character of String is: G Last character of String is: s37
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s51
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life29
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life13
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s3
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]7
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: 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: s66
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 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: s70
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s71
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s29
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s70
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s1
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life68
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 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: s80
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 String: GeeksForGeeks First character of String is: G Last character of String is: s37
Các
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s95
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
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: s98
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s3
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]00
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 blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]02
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]04
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']]07
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 blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]10
Output:
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']]
Lưu ý - Tạo ra tuple python mà không sử dụng dấu ngoặc đơn được gọi là đóng gói tple.– Creation of Python tuple without the use of parentheses is known as Tuple Packing.
Truy cập các yếu tố của tuple
Để truy cập các mục Tuple, hãy tham khảo số chỉ mục. Sử dụng toán tử chỉ mục
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life82 để truy cập vào một mục trong một tuple. Chỉ số phải là một số nguyên. Các bộ dữ liệu lồng nhau được truy cập bằng cách sử dụng lập chỉ mục lồng nhau.
Python3
Is
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']]28
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]29
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s0
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]31
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life04
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]25
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']]36
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]29
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s0
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]31
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life12
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life13
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]25
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']]45
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]29
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s0
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]31
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life12
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s26
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]25
Output:
First element of tuple 1 Last element of tuple 5 Third last element of tuple 3
Lưu ý - Để biết thêm về các bộ dữ liệu, hãy tham khảo các bộ dữ liệu python.– To know more about tuples, refer Python Tuples.
Boolean
Kiểu dữ liệu với một trong hai giá trị tích hợp,
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]52or
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]53. Các đối tượng Boolean bằng với sự thật là sự thật [đúng] và những đối tượng bằng sai là giả [sai]. Nhưng các đối tượng không phải là Boolean cũng có thể được đánh giá trong bối cảnh Boolean và được xác định là đúng hoặc sai. Nó được ký hiệu là lớp
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]54.
Lưu ý - Đúng và Sai với vốn ’T, và F, là Booleans hợp lệ nếu không Python sẽ gây ra lỗi.– True and False with capital ‘T’ and ‘F’ are valid booleans otherwise python will throw an error.
Python3
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
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']]59
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]60
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
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']]53
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]60
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
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]70
Output:
Traceback [most recent call last]: File "/home/7e8862763fb66153d70824099d4f5fb7.py", line 8, in print[type[true]] NameError: name 'true' is not defined
Bộ
Trong Python, Set là một tập hợp các loại dữ liệu không có thứ tự là có thể sử dụng được, có thể thay đổi và không có các yếu tố trùng lặp. Thứ tự của các phần tử trong một bộ không được xác định mặc dù nó có thể bao gồm các yếu tố khác nhau.
Tạo bộ
Các bộ có thể được tạo bằng cách sử dụng hàm
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]71 tích hợp với một đối tượng có thể lặp lại hoặc một chuỗi bằng cách đặt chuỗi bên trong niềng răng xoăn, được phân tách bằng ‘dấu phẩy. Loại phần tử trong một tập hợp không cần phải giống nhau, các giá trị loại dữ liệu hỗn hợp khác nhau cũng có thể được chuyển đến tập hợp.
Python3
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]72
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]74
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s31
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']]78
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 blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]81
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]72
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]74
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s1
Initial blank Set: set[] Set with the use of String: {'F', 'o', 'G', 's', 'r', 'k', 'e'} Set with the use of List: {'Geeks', 'For'} Set with the use of Mixed Values {1, 2, 4, 6, 'Geeks', 'For'}1
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 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']]90
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 blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]81
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]72
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]74
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]15
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life43
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s3
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life45
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: s0
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s1
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks06
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 blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]81
Cá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
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks30
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 blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]81
Output:
Initial blank Set: set[] Set with the use of String: {'F', 'o', 'G', 's', 'r', 'k', 'e'} Set with the use of List: {'Geeks', 'For'} Set with the use of Mixed Values {1, 2, 4, 6, 'Geeks', 'For'}
Truy cập các yếu tố của các bộ
Đặt các mục không thể được truy cập bằng cách tham khảo một chỉ mục, vì các bộ không được đặt hàng nên các mục không có chỉ mục. Nhưng bạn có thể lặp qua các mục đã đặt bằng cách sử dụng vòng lặp cho vòng lặp hoặc hỏi xem giá trị được chỉ định có xuất hiện trong một tập hợp không, bằng cách sử dụng
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks34Keyword.
Python3
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]72
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]74
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]15
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life43
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s3
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life45
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: s0
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s1
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks47
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 blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]81
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
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks53
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
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks55
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks56
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks57
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks58
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks59
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s0
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks61
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks63
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 String: GeeksForGeeks First character of String is: G Last character of String is: s1
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life43
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks57
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks69
Output:
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life0
Lưu ý - Để biết thêm về các bộ, tham khảo các bộ Python. To know more about sets, refer Python Sets.
Từ điển
Từ điển trong Python là một tập hợp các giá trị dữ liệu không được đặt hàng, được sử dụng để lưu trữ các giá trị dữ liệu như bản đồ, không giống như các loại dữ liệu khác chỉ chứa một giá trị đơn như một phần tử, từ điển giữ
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks70Pair. Giá trị khóa được cung cấp trong từ điển để làm cho nó được tối ưu hóa hơn. Mỗi cặp giá trị khóa trong một từ điển được phân tách bằng một đại tràng
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks71, trong khi mỗi khóa được phân tách bằng một dấu phẩy.
Tạo từ điển
Trong Python, một từ điển có thể được tạo bằng cách đặt một chuỗi các phần tử trong niềng răng xoăn
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks72, được phân tách bằng ‘dấu phẩy. Các giá trị trong từ điển có thể thuộc bất kỳ kiểu dữ liệu nào và có thể được nhân đôi, trong khi các khóa có thể được lặp lại và phải là bất biến. Từ điển cũng có thể được tạo bởi chức năng tích hợp
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks73. Một từ điển trống có thể được tạo bằng cách chỉ đặt nó vào niềng răng xoăn {}.
Lưu ý - Khóa từ điển nhạy cảm, cùng tên nhưng các trường hợp khóa khác nhau sẽ được xử lý rõ ràng.– Dictionary keys are case sensitive, same name but different cases of Key will be treated distinctly.
Python3
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks74
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks76
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
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks79
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 String: GeeksForGeeks First character of String is: G Last character of String is: s1
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks74
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
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks74
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks87
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life13
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks89
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life68
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s3
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]7
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks89__
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']]02
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 String: GeeksForGeeks First character of String is: G Last character of String is: s1
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks74
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
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks74
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks87
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']]11
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks89
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life68
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s3
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life13
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']]16__
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']]27
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 String: GeeksForGeeks First character of String is: G Last character of String is: s1
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks74
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
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks74
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
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']]35
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']]36
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life13
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks89
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life68
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s3
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]7__
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']]51
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 String: GeeksForGeeks First character of String is: G Last character of String is: s1
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks74
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
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks74
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
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']]35
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']]60
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life13
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s3
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life68
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']]64
Initial blank List: [] List with the use of String: ['GeeksForGeeks'] List containing multiple values: Geeks Geeks Multi-Dimensional List: [['Geeks', 'For'], ['Geeks']]7__
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']]71
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 String: GeeksForGeeks First character of String is: G Last character of String is: s1
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks74
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
Output:
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life1
Truy cập các yếu tố của từ điển
Để truy cập các mục của từ điển, hãy tham khảo tên khóa của nó. Khóa có thể được sử dụng bên trong dấu ngoặc vuông. Ngoài ra còn có một phương pháp gọi là
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']]77 cũng sẽ giúp truy cập phần tử từ từ điển.
Python3
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks74
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life8
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks87
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life13
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks89
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life68
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s3
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']]85___
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']]95
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 String: GeeksForGeeks First character of String is: G Last character of String is: s1
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks74
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life29
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']]85
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life05
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 305
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 String: GeeksForGeeks First character of String is: G Last character of String is: s1
Accessing element from the list Geeks Geeks Accessing element using negative indexing Geeks Geeks74
First element of tuple 1 Last element of tuple 5 Third last element of tuple 310
Initial String: GeeksForGeeks First character of String is: G Last character of String is: s26
First element of tuple 1 Last element of tuple 5 Third last element of tuple 312
Output:
String with the use of Single Quotes: Welcome to the Geeks World String with the use of Double Quotes: I'm a Geek String with the use of Triple Quotes: I'm a Geek and I live in a world of "Geeks" Creating a multiline String: Geeks For Life2