Python Data Types

Sajjad RahmanSajjad Rahman
2 min read

In Python, data types determine the type of data that a variable can hold. Different data types have different purposes. Here I am going to write some types of data type

Integer (int)

Integers are whole numbers without decimal points. Examples:

age = 25
height = 175
students_count = 1000

Floating-Point (float)

Floating-point numbers are numbers with decimal points. Examples:

pi = 3.14159
temperature = 25.5
weight = 68.75

String (str)

Strings are sequences of characters enclosed in single (' ') or double (" ") quotes. Examples:

name = "John Doe"
address = '123 Main Street'
message = "Hello, how are you?"

Boolean (bool)

Booleans represent truth values. It can be either True or False. Examples:

is_raining = True
is_sunny = False
is_student = True

List

numbers = [1, 2, 3, 4, 5]
names = ['Alice', 'Bob', 'Charlie']
mixed_list = [10, 'apple', True, 3.14]

Tuple

Tuples are similar to lists, but they are immutable once created. Examples

axiz = (10, 20)
marks = (55, 78, 90)

Dictionary

Dictionaries store key-value pairs and allow accessing values using their keys. Dictionaries are mutable. Examples:

person = {"name": "John", "age": 30, "city": "New York"}
grades = {"math": 90, "science": 85, "history": 78}

Set

Sets are unordered collections of unique elements ( no duplicate) Examples:

fruits = {'apple', 'banana', 'orange'}
prime_numbers = {2, 3, 5, 7, 11}

NoneType (None)

None is a special data type representing the absence of a value. Example:

result = None

These are some of the essential data types in Python. Understanding data types is crucial for effectively manipulating and processing data in your Python programs. Remember that Python is a dynamically-typed language, meaning you do not need to specify the data type explicitly when declaring a variable; Python will infer it based on the assigned value.

๐Ÿ’ก
Comment your thoughts

๐Ÿฆ Twitter: @sajjadrahman56 ๐Ÿฆ

๐Ÿ™ GitHub: sajjadrahman56 ๐Ÿ™

๐Ÿ”— LinkedIn: sajjadrahman56

Sajjad Rahman

Stay connected and follow me on my social media accounts to keep up with my latest updates and projects! ๐ŸŒŸ Let's collaborate and share knowledge together. ๐Ÿค Looking forward to engaging with you in the tech community! ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

1
Subscribe to my newsletter

Read articles from Sajjad Rahman directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sajjad Rahman
Sajjad Rahman

As a Flutter developer, I am constantly learning and trying to implement new concepts into my projects. In addition, I devote time to studying Machine Learning. I have a passion for contributing to open-source projects.