data types in python
What is datatypes ?
In simple terms, data types refer to the kind of value that a variable holds. For instance, a variable could hold a string of text, a number, or even a list of values. In Python, the language has a built-in support for various data types. These data types are essential in Python since they define the operations that can be performed on a given variable. Knowing the data type of a variable allows you to perform the correct operations on it, which helps to avoid errors and enhance the performance of your code.
Datatypes:
- numbers
- string
- bool
- dic
- tuple
- set
- list
Note : We do not need to specify the datatype explicitly , it based on values type on allocated automatically
Python is a dynamically typed language.
For Example:
int a=2 (We don't need to decleare datatype )( Wrong )
a=2 ( python automatically declare integer datatype )( Correct )
a=2.4 ( python automatically declare float datatype )( Correct )
a=True( python automatically declare boolean datatype )( Correct )
What is variable ?
Variable is the name of memory location where we can store different types of values.
IF you find that what type of data put in python program then you need to use type() function.
type() function :
It return the datatype of the given value.
If you have any problem watch this video
data types in python
Like Share & Subscribe My Channel