• Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
AnonyViet - English Version
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
AnonyViet - English Version
No Result
View All Result

Basic data types in Python

AnonyViet by AnonyViet
January 9, 2026
in Tips
0

Data types are one of the most important components of python. You can do a lot of interesting things with these data types. It is a fact that in python, all data types are objects.

Join the channel Telegram belong to AnonyViet 👉 Link 👈

Basic data types in Python

Data type is like a characteristic of the type of data you want to store in memory and python has some of the following built-in data types:

  • String text type: str
  • Number type: int, float, complex
  • Sequence types: list, tuple, range
  • Mapping type: dict
  • Set data type: set, frozenset
  • Boolean type: bool
  • Binary type: byte, bytearray, memoryview

Now, let’s classify all these data types using functions type() to display the variable’s data type.

Text format

String data type str

str is short for string used to store text in python. Strings can be written in double or single quotes, so you can write like this:

For example:

String data type str python

Result:

Hello, world!

Number type

Integer data type int

int is short for integer (integer) used to store integers (positive and negative integers).

For example:

Python integer data type

Result:

4

Float real number data type

float stands for real number (decimal number).

For example:

Python float data type

Result:

3.14

Complex numbers have real parts and imaginary parts, each part is a real number. Complex numbers can be written in two forms: real + (imag)jcomplex(real, imag).

For example:

Basic data types in Python 17

Result:

(5+10j)

Sequence type data type

list. list

List is a data type where you can store a collection of data. List can also contain different data types. List can also sort, change elements and allow elements to appear duplicated

For example:

Basic data types in Python 18

Result:

['Captain America', 'Iron Man', 'Thor', 'Hulk', 'Black Widow', 'Hawkeye']

tuple

Tuple is a data type where you can store a collection of data. Tuples can also contain different data types. Tuples are sortable, elements cannot be changed, and duplicate elements are allowed.

For example:

Basic data types in Python 19

Result:

('Captain America', 'Iron Man', 'Thor', 'Hulk', 'Black Widow', 'Hawkeye')

range. range

The range type represents an immutable (unchangeable) series of numbers. Usually used to repeat a specific number of times in a for loop.

For example:

Basic data types in Python 20

Result:

range(0, 10)

Mapping data type

dict

dict is short for dictionary in python. Dict is used to store data values ​​in key:values. A Dict is an unordered, mutable collection that does not allow duplicates.

For example:

Basic data types in Python 21Result:

{'Learning': 'Programming', 'Language': 'Python', 'Day': 4}

Data type Set

set

set is a data type where you can contain a collection of data. Sets can also contain different data types. Sets are unordered and unindexed, and duplicate elements are not allowed.

For example:

Basic data types in Python 22

Result:

{'Black Widow', 'Iron Man', 'Thor', 'Hawkeye', 'Hulk', 'Captain America'}

frozenset

The frozenset data type can be created by the function frozenset(). Jaw frozenset() accepts an iterable object and returns an immutable frozenset object (like a set object, just immutable).

For example:

Basic data types in Python 23

Result:

frozenset({'cherry', 'banana', 'apple'})

Boolean type

bool

bool stands for boolean in python. Booleans represent one of two values: True or False.

For example:

Basic data types in Python 24

Result:

True

False

Binary type

bytes

The byte data type can be created in two forms: using the byte() function or using the prefix “b”.

For example:

Basic data types in Python 25

Result:

b'hello'

b'Hello'

bytearray

Jaw bytearray() returns a bytearray object. It can convert objects to bytearray objects.

For example:

Basic data types in Python 26

Result:

bytearray(b'\x00\x00\x00\x00')

memoryview

jaw memoryview() returns an object in memory view of a specified object.

For example:

Basic data types in Python 27

Result:

As you have seen, some data types can also be implemented using their constructors. This same technique can be applied to any data type.

For example:

Basic data types in Python 28

Result:

Hello, World!
4
3.14
(5+10j)
['Captain America', 'Iron Man', 'Thor', 'Hulk', 'Black Widow', 'Hawkeye']
('Captain America', 'Iron Man', 'Thor', 'Hulk', 'Black Widow', 'Hawkeye')
range(0, 10)
{'Learning': 'Programming', 'Language': 'Python', 'Day': 4}
{'apple', 'cherry', 'banana'}
frozenset({'banana', 'cherry', 'apple'})
True
False
b'\x00\x00\x00\x00'
bytearray(b'\x00\x00\x00\x00')

If you support and I see that the view of this article is high, I will do a few more articles comparing data types in python. So please support me.

Frequently asked questions

How many basic data types does Python have?

Python provides many basic data types, including numeric types (int, float, complex), string types (str), sequence types (list, tuple, range), map types (dict), set types (set, frozenset), Boolean types (bool), and binary types (bytes, bytearray, memoryview).

How to determine the data type of a variable in Python?

Use functions type(). For example: type(my_variable) will return the data type of the variable my_variable.

What is the difference between list and tuple in Python?

Both list and tuple are sequential data types, but list is mutable and tuple is immutable. This means you can add, remove, or modify elements in a list, but you can’t do that with a tuple.

Previous Post

Share IObit Uninstaller 15 PRO license key for free 2026

Next Post

Screen recording on Windows 10 does not require software installation

AnonyViet

AnonyViet

Related Posts

How to record reaction videos with Android phones, no app needed
Tips

How to record reaction videos with Android phones, no app needed

June 1, 2026
Instructions on how to get Google AI Pro 1 year for free for new accounts
Tips

Instructions on how to get Google AI Pro 1 year for free for new accounts

June 1, 2026
Top free AI tools to help write, test and optimize content
Tips

Top free AI tools to help write, test and optimize content

June 1, 2026
Instructions for receiving Lovable Pro 12 months for free
Tips

Instructions for receiving Lovable Pro 12 months for free

May 29, 2026
Instructions for receiving 1 month of ElevenLabs Creator for free worth
Tips

Instructions for receiving 1 month of ElevenLabs Creator for free worth $22

May 25, 2026
How to create beautiful studio-like preschool graduation photos for your child
Tips

How to create beautiful studio-like preschool graduation photos for your child

May 21, 2026
Next Post
Screen recording on Windows 10 does not require software installation

Screen recording on Windows 10 does not require software installation

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

How to record reaction videos with Android phones, no app needed

How to record reaction videos with Android phones, no app needed

June 1, 2026
Instructions on how to get Google AI Pro 1 year for free for new accounts

Instructions on how to get Google AI Pro 1 year for free for new accounts

June 1, 2026
Top free AI tools to help write, test and optimize content

Top free AI tools to help write, test and optimize content

June 1, 2026
TruyenDrive: Turn Google Drive into a professional manga reader

TruyenDrive: Turn Google Drive into a professional manga reader

May 31, 2026
How to record reaction videos with Android phones, no app needed

How to record reaction videos with Android phones, no app needed

June 1, 2026
Instructions on how to get Google AI Pro 1 year for free for new accounts

Instructions on how to get Google AI Pro 1 year for free for new accounts

June 1, 2026
Top free AI tools to help write, test and optimize content

Top free AI tools to help write, test and optimize content

June 1, 2026
AnonyViet - English Version

AnonyViet

AnonyViet is a website share knowledge that you have never learned in school!

We are ready to welcome your comments, as well as your articles sent to AnonyViet.

Follow Us

Contact:

Email: anonyviet.com[@]gmail.com

Main Website: https://anonyviet.com

Recent News

How to record reaction videos with Android phones, no app needed

How to record reaction videos with Android phones, no app needed

June 1, 2026
Instructions on how to get Google AI Pro 1 year for free for new accounts

Instructions on how to get Google AI Pro 1 year for free for new accounts

June 1, 2026
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply