-
Hajipur, Bihar, 844101
Hajipur, Bihar, 844101
Introduction to Python
Python Basics
Python Syntax
Python Comments
Python Variables
Python Data Types
Python Casting
Python I/O
Python Operators
Cotrol Structures
Data Structures
Python Strings
Python Lists
Python Tuples
Python Dictionaries
Python Sets
Python Arrays
Python Bytes and Bytearray
Date and Time
Functions and Module
File Handling
Python OOP
Advanced Concepts
Python Scope
Python Modules
Python JSON
Python RegEx
Python PIP
Python Try...Except
Python String Formatting
Python User Input
Python VirtualEnv
Python Math
Python DSA
Python DSA
Lists and Arrays
Python Stacks
Python Queues
Linked Lists
Python Hash Tables
Python Trees
Python Binary Trees
Binary Search Trees
Python AVL Trees
Python Graphs
Searching Algorithms
Sorting Algorithms
In Python, everything is an object, and every object has a data type.
A data type defines what kind of value a variable can hold and how it can be used.
Python automatically assigns the correct data type when you assign a value to a variable.
Category | Data Types |
---|---|
Text Type | str |
Numeric Types | int , float , complex |
Sequence Types | list , tuple , range |
Mapping Type | dict |
Set Types | set , frozenset |
Boolean Type | bool |
Binary Types | bytes , bytearray , memoryview |
None Type | NoneType |
int
: Whole numbers (e.g., 5, -10, 100)
float
: Decimal numbers (e.g., 3.14, -0.99)
complex
: Complex numbers (e.g., 2 + 3j)
str
: A sequence of Unicode characters (e.g., "hello", 'Python')
list
: Ordered, changeable, allows duplicates
Example: [1, 2, 3]
tuple
: Ordered, unchangeable, allows duplicates
Example: (1, 2, 3)
range
: Used for looping a sequence of numbers
Example: range(5)
dict
: Key-value pairs
Example: {"name": "Alice", "age": 25}
bool
: Only two values — True
or False
Often used in comparisons and conditions.
set
: Unordered, no duplicates
Example: {1, 2, 3}
frozenset
: Like set, but immutable
Used for binary data:
bytes
bytearray
memoryview
NoneType
: Represents a null value
Example: x = None
Use type()
to check the data type of a variable.
x = 10
print(type(x)) # Output: <class 'int'>
Type | Example Value | Type Name |
---|---|---|
Text | "Hello" |
str |
Integer | 10 |
int |
Float | 3.14 |
float |
Boolean | True |
bool |
List | [1, 2, 3] |
list |
Tuple | (1, 2, 3) |
tuple |
Dictionary | {"a": 1} |
dict |
Set | {1, 2, 3} |
set |
None | None |
NoneType |
Q1. Write a Python program to create a variable with your name and check its type using the type()
function.
Q2. Write a Python program to assign a floating-point number to a variable and display its type.
Q3. Write a Python program to create a list of 5 fruits and print the list.
Q4. Write a Python program to create a tuple of 3 colors and print it.
Q5. Write a Python program to define a dictionary containing your name and age, then print it.
Q6. Write a Python program to create a set with repeated values and observe how duplicates are handled.
Q7. Write a Python program to check the type of a boolean value stored in a variable.
Q8. Write a Python program to create a variable with a complex number and print it.
Q9. Write a Python program to assign None
to a variable and check its type using type()
.
Q10. Write a Python program to create a range of numbers from 1 to 10 and convert it into a list using list()
.
Introduction to Python
Python Basics
Python Syntax
Python Comments
Python Variables
Python Data Types
Python Casting
Python I/O
Python Operators
Cotrol Structures
Data Structures
Python Strings
Python Lists
Python Tuples
Python Dictionaries
Python Sets
Python Arrays
Python Bytes and Bytearray
Date and Time
Functions and Module
File Handling
Python OOP
Advanced Concepts
Python Scope
Python Modules
Python JSON
Python RegEx
Python PIP
Python Try...Except
Python String Formatting
Python User Input
Python VirtualEnv
Python Math
Python DSA
Python DSA
Lists and Arrays
Python Stacks
Python Queues
Linked Lists
Python Hash Tables
Python Trees
Python Binary Trees
Binary Search Trees
Python AVL Trees
Python Graphs
Searching Algorithms
Sorting Algorithms