Course Content
Python Indentation, Comments and Variables
0/2
Object Oriented Programming in Python
0/1
Exception Handling in Python
0/1
Sending emails with Python
0/1
Unit test in python programming
0/1
Python programming (zero to advance!!!)
About Lesson

In Python, data types represent the kind of value that tells what operations can be performed on a particular data. Python supports several built-in data types, each serving a specific purpose. Here’s an overview of the commonly used data types in Python:

1. Numeric Types:
– int: Integer type represents whole numbers without any fractional part.
– float: Floating-point type represents real numbers with a decimal point.

2. Sequence Types:
– str: String type represents a sequence of characters, enclosed within single quotes (”), double quotes (“”) or triple quotes (”’ or “””).
– list: List type represents an ordered collection of items, mutable (modifiable) and enclosed within square brackets ([]).
– tuple: Tuple type represents an ordered collection of items, immutable (unchangeable) and enclosed within parentheses (()).

3. Boolean Type:
– bool: Boolean type represents truth values, either True or False.

4. Mapping Type:
– dict: Dictionary type represents a collection of key-value pairs, enclosed within curly braces ({}) and separated by commas (,).

5. Set Types:
– set: Set type represents an unordered collection of unique elements, enclosed within curly braces ({}) and separated by commas (,).
– frozenset: Frozenset type represents an immutable set, similar to set but cannot be modified after creation.

6. None Type:
– None: None type represents the absence of a value or a null value in Python.

Here’s a quick example demonstrating the usage of these data types:

“`python
# Numeric Types
num_int = 10
num_float = 3.14

# Sequence Types
str_var = “Hello, World!”
list_var = [1, 2, 3, 4, 5]
tuple_var = (10, 20, 30, 40, 50)

# Boolean Type
bool_var = True

# Mapping Type
dict_var = {‘name’: ‘John’, ‘age’: 30}

# Set Types
set_var = {1, 2, 3, 4, 5}
frozenset_var = frozenset({1, 2, 3, 4, 5})

# None Type
none_var = None
“`

Understanding and working with these data types is fundamental to writing effective Python code. Each data type has its own set of methods and operations that you can perform on them, allowing for versatile programming capabilities in Python.

Join the conversation