• 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

Instructions for cleaning LG TV with Antigravity to help it run faster
Tips

Instructions for cleaning LG TV with Antigravity to help it run faster

October 30, 2026
Quét lỗ hổng bảo mật cho Vide Coding bằng Security Audit Skill
Tips

Quét lỗ hổng bảo mật cho Vide Coding bằng Security Audit Skill

October 27, 2026
Instructions for registering for OxionAI Pro for 1 year with many powerful AI models
Tips

Instructions for registering for OxionAI Pro for 1 year with many powerful AI models

October 24, 2026
How are Windows 11 Pro and Windows 10 Pro different?
Tips

How are Windows 11 Pro and Windows 10 Pro different?

October 23, 2026
Instructions for using CleanYourTV: Remove ads on Android TV, Google TV
Tips

Instructions for using CleanYourTV: Remove ads on Android TV, Google TV

October 23, 2026
How to use Messenger without a Facebook account
Tips

How to use Messenger without a Facebook account

October 22, 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

Recent News

Instructions for receiving Avira Prime 3 months for free, no credit card

Instructions for receiving Avira Prime 3 months for free, no credit card

October 31, 2026
Instructions for cleaning LG TV with Antigravity to help it run faster

Instructions for cleaning LG TV with Antigravity to help it run faster

October 30, 2026
Cách hạn chế Synology NAS bị Ransomware .L0CK3D: Cách khắc phục

Cách hạn chế Synology NAS bị Ransomware .L0CK3D: Cách khắc phục

October 30, 2026
Instructions for installing CleanYourTv to remove Android TV ads

Instructions for installing CleanYourTv to remove Android TV ads

October 29, 2026
Instructions for receiving Avira Prime 3 months for free, no credit card

Instructions for receiving Avira Prime 3 months for free, no credit card

October 31, 2026
Instructions for cleaning LG TV with Antigravity to help it run faster

Instructions for cleaning LG TV with Antigravity to help it run faster

October 30, 2026
Cách hạn chế Synology NAS bị Ransomware .L0CK3D: Cách khắc phục

Cách hạn chế Synology NAS bị Ransomware .L0CK3D: Cách khắc phục

October 30, 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

Instructions for receiving Avira Prime 3 months for free, no credit card

Instructions for receiving Avira Prime 3 months for free, no credit card

October 31, 2026
Instructions for cleaning LG TV with Antigravity to help it run faster

Instructions for cleaning LG TV with Antigravity to help it run faster

October 30, 2026
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

say88 tỷ lệ kèo nhà cái kèo nhà cái 5 febet

No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

say88 tỷ lệ kèo nhà cái kèo nhà cái 5 febet

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