Professional Documents
Culture Documents
Continued……
1. Number :
In python, in number data type we have 3 types those are Integer, Float
and Complex they are explained as follows:
In Python, the number data type is used to represent numerical values. There are
primarily three types of numerical data types in Python:
Python provides built-in functions and operators to work with numeric data
types. Here are some common operations:
In Python, the string data type (str) is used to represent sequences of characters.
Strings are immutable, meaning they cannot be modified after creation. They
are one of the most commonly used data types in Python and are used to store
textual data.
Strings can be created using single quotes (') or double quotes ("). Both are
equivalent, and you can choose either based on your preference or to handle
situations where one type of quote is embedded within the string.
Python also supports triple-quoted strings (''' or """) which can span multiple
lines. These are often used for docstrings (documentation strings) or for
representing multiline text.
Strings are versatile and extensively used in Python programming for tasks such
as text processing, data manipulation, input/output handling, and more.
Positive Indexing starts from 0 from right-hand-side and Negative Indexing
starts from -1 from left-hand-side
The string data type (str) in Python comes with a variety of built-in methods
that allow you to manipulate, search, and transform strings. Here are some
commonly used string methods in Python:
1. Conversion Methods:
• capitalize(): Returns a copy of the string with the first character
capitalized and the rest lowercase.
• upper(): Returns a copy of the string with all characters converted
to uppercase.
• lower(): Returns a copy of the string with all characters converted
to lowercase.
• swapcase(): Returns a copy of the string with uppercase characters
converted to lowercase and vice versa.
• title(): Returns a copy of the string with the first character of each
word capitalized.
These are just some of the most commonly used string methods in Python.
There are many more available for various purposes. You can explore these
methods and their detailed usage in the Python documentation or experiment
with them interactively in the Python interpreter or in your favorite IDE.
3. List :
In Python, a tuple is a built-in data type similar to a list, but with a few
key differences. Like lists, tuples are used to store collections of items,
but unlike lists, tuples are immutable, meaning their elements cannot be
changed after creation. Tuples are defined using parentheses () and
elements are separated by commas. Here's an example of a tuple:
Methods of List Data type in Python
Methods of Tuples data type in Python
Sets Data Type in Python:
In Python, a set is a built-in data type used to store unique elements. Sets are
unordered collections of distinct objects, meaning each element appears only
once in the set. Sets are defined using curly braces {} or the set() constructor,
with elements separated by commas. Here's an example of a set:
Here are some common methods and operations associated with sets:
Dictionary Data Type in Python