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
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
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
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
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
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
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
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
6 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:
s
0Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
1Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
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
4Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
5Float - 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:
s
0Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
1Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
1Initial 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
4Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
4Số 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
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
6 được sử dụng để xác định loại loại dữ liệu.Output: Type of a: <class 'int'>
Type of b: <class 'float'>
Type of c: <class 'complex'>
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
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
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
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
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
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
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+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 Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
6 đượ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 Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
7String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
9Initial 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
1Initial 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'))
2Initial 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'))
3Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0Initial 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'))
5Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
6String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
8Initial 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
1First element of tuple
1
Last element of tuple
5
Third last element of tuple
3
1Initial 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'))
3Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0Initial 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'))
5Initial 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
1Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
4First element of tuple
1
Last element of tuple
5
Third last element of tuple
3
8Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
7String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
5String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 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']]
9Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0Initial 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'))
5Initial 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
1Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
4First element of tuple
1
Last element of tuple
5
Third last element of tuple
3
8Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
7String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8Initial 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
1Traceback (most recent call last):
File "/home/7e8862763fb66153d70824099d4f5fb7.py", line 8, in
print(type(true))
NameError: name 'true' is not defined
5Initial 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'))
3Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0Initial 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'))
5Output: String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
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 - Python3Sợi dây 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
1Initial 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'}
4Initial 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'))
3Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0Initial 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'))
5Initial 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
1String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
00Initial 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'))
3Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
03String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
04String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
05Initial 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
1String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
08Initial 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'))
3Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
03String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
12String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
13String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
05Output:
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. Tuple1) 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
Python3Chuỗ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:
s
0Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
1String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
21Initial 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'))
3Initial 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
1String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
16Initial 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'))
3Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
7String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
9Initial 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
1String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
34Initial 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'))
3Initial 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
1String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
16Initial 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'))
3Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
7String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 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'))
8Initial 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
1<class 'bool'>
<class 'bool'>
3Initial 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'))
3Initial 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
1String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
16String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
29String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
04String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
58Initial 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
1String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
16String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
29Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
7String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
05Truy 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:
s
0Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
1String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
76Initial 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'))
3Initial 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
1String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
16Initial 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'))
3Output: 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
Geeks
7String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 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'}
1Python3String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
16 String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
29String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
43Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
3String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
45Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
3String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
43__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
1String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
96Initial 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:
s
0Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
1String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
16String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
29Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
7String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
05Initial 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
1Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
12Initial 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'))
3Initial 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
1String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
16String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
29String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
12String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
13String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
05Initial 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
1String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
16String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
29String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
12Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
26String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
05Output: 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) TupleGiố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 tupleTrong 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. Python3Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
29String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
31Initial 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
1Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
34Initial 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'))
3Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0 Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
37Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
29String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
1String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
68Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
3String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
70Initial 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'))
3Initial 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
1Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
47Initial 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'))
3Initial 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
37Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
51String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
29String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
13Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
3Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
7Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
3__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
1Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
66Initial 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'))
3Initial 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
1Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
70Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
71Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
29String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
70Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
1String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
68Initial 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'))
3Initial 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
1Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
80Initial 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'))
3Initial 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
37Các Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
95String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
1Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
98Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
3Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
00Initial 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'))
3Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
02String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
04Initial 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
1Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
07Initial 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'))
3Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
10Output: 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
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
82 để 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.Python3Is 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
1Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
28Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
29Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
31String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
04Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
25Initial 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
1Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
36Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
29Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
31String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
12String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
13Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
25Initial 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
1Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
45Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
29Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
31String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
12Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
26Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
25Output: 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. BooleanKiể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. Python3Initial 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
1Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
4Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
1Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
59Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
60Initial 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
1Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
4Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
1Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
53Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
60Initial 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
1Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
4Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
70Output: <class 'bool'>
<class 'bool'>
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.
Python3Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
72String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
74Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
31Initial 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
1Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
78Initial 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'))
3Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
81Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
72String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
74Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
1Initial 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'}
1Initial 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'))
3Initial 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
1Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
90Initial 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'))
3Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
81Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
72String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
74Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
15String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
43Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
3String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
45Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
3__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
06Initial 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'))
3Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
81Các 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
30Initial 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'))
3Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
81Output: 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
Geeks
34Keyword.Python3Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
72String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
74Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
15String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
43Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
3String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
45Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
3__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
47Initial 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'))
3Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
81Initial 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
53Initial 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'))
3Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
55 Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
56Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
57 Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
58Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
59Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
0Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
61String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
63Initial 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'))
3Initial 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
1String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
43 Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
57 Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
69Output: String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
0Lư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ểnTừ đ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
Geeks
70Pair. 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
Geeks
71, trong khi mỗi khóa được phân tách bằng một dấu phẩy.Tạo từ điểnTrong 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
Geeks
72, đượ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
Geeks
73. 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. Python3Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
74 String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
76Initial 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
79Initial 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'))
3Initial 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
74Initial 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'))
3Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
74 String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
87String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
13Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
89String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
68Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
3Initial blank List:
[]
List with the use of String:
['GeeksForGeeks']
List containing multiple values:
Geeks
Geeks
Multi-Dimensional List:
[['Geeks', 'For'], ['Geeks']]
7Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
89__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
1Initial 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'))
02Initial 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'))
3Initial 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
74Initial 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'))
3Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
74 String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
87Initial 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'))
11Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
89String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
68Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
3String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
13Initial 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:
s
0Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
1Initial 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'))
27Initial 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'))
3Initial 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
74Initial 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'))
3Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
74 String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 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'))
35Initial 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'))
36String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
13Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
89String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
68Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
3Initial 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:
s
0Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
1Initial 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'))
51Initial 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'))
3Initial 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
74Initial 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'))
3Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
74 String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 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'))
35Initial 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'))
60String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
13Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
3String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
68Initial 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'))
64Initial 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:
s
0Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
1Initial 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'))
71Initial 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'))
3Initial 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
74Initial 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'))
3Output: String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
1Truy 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.Python3Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
74 String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
8 Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
87String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
13Accessing element from the list
Geeks
Geeks
Accessing element using negative indexing
Geeks
Geeks
89String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
68Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
3Initial 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:
s
0Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
1Initial 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'))
95Initial 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'))
3Initial 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
74String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
29Initial 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'))
85String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
05Initial 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
1First element of tuple
1
Last element of tuple
5
Third last element of tuple
3
05Initial 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'))
3Initial 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
74First element of tuple
1
Last element of tuple
5
Third last element of tuple
3
10Initial String:
GeeksForGeeks
First character of String is:
G
Last character of String is:
s
26First element of tuple
1
Last element of tuple
5
Third last element of tuple
3
12Output: String with the use of Single Quotes:
Welcome to the Geeks World
String with the use of Double Quotes:
I'm a Geek
<class 'str'>
String with the use of Triple Quotes:
I'm a Geek and I live in a world of "Geeks"
<class 'str'>
Creating a multiline String:
Geeks
For
Life
2
Kiểu dữ liệu số trong Python là gì?
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à một số nguyên, số nổi hoặc thậm chí là số phức. Các giá trị này được định nghĩa là int, float và các lớp phức tạp trong Python.represents the data that has a numeric value. The numeric value can be an integer, floating number, or even complex number. These values are defined as int, float, and complex classes in Python.
Kiểu dữ liệu số giải thích với ví dụ là gì?
Các loại dữ liệu số là các số được lưu trữ trong các cột cơ sở dữ liệu.Các loại dữ liệu này thường được nhóm lại bởi: các loại số chính xác, các giá trị trong đó độ chính xác và tỷ lệ cần được bảo tồn.Các loại chính xác là số nguyên, lớn, thập phân, số, số và tiền.numbers stored in database columns. These data types are typically grouped by: Exact numeric types, values where the precision and scale need to be preserved. The exact numeric types are INTEGER , BIGINT , DECIMAL , NUMERIC , NUMBER , and MONEY .
4 loại dữ liệu số trong Python là gì?
Trong Python, 4 loại dữ liệu số tích hợp là:.. INT: Đây là số lượng toàn bộ phạm vi không giới hạn..... Long: Đây là những số nguyên dài trong Python 2. .... Float: Đây là các số điểm nổi được biểu thị là số chính xác gấp đôi 64 bit..... phức tạp: là những con số không dấu với các thành phần thực và tưởng tượng ..
3 loại dữ liệu số trong Python là gì?
Các loại số - int, float, phức tạp.Có ba loại số riêng biệt: số nguyên, số điểm nổi và số phức.integers, floating point numbers, and complex numbers. |