Data Type in python a Dynamically-typed language - DeveloperIndian
Python famous as dynamic type language , so no need to define data type explicitly in python. Dynamically-typed language is a programming language in which the data type of a variable is determined at runtime, as opposed to being explicitly declared in the source code. In dynamically-typed languages, the type of a variable can change during the execution of a program.
You can explore number ,string ,boolean,bytes so many others.
-
Numeric data types: int, float, complex.
-
String data types: str.
-
Sequence types: list, tuple, range.
-
Binary types: bytes, bytearray, memoryview.
-
Mapping data type: dict.
-
Boolean type: bool.
-
Set data types: set, frozenset. Python Numeric Data Type. Python numeric data type is used to hold numeric values like;
Example First
sum = 0
for i in range (10):
sum += i
Example second
sum = 0
while sum!=10 :
sum += 1;
Feature of Python Language
-
Robust Standard Library.
-
Supports multiple programming paradigms
-
Compiled as well as Interpreted
-
Cross Platform
-
Extensible you can add module in your project or code.
-
Huge Library - Many library are awailable
-
Easy-to-learn − Python has few keywords, simple structure, and a similar to c language.
-
Easy-to-read − Python code is more clearly if you know c language .
-
Easy-to-maintain − Python's source code is easy-to-maintain and structure file.
-
Dynamically typed language
Conclusion :
Python is a dynamically-typed language, which means that you don't need to declare the data type of a variable explicitly. Python infers the data type based on the value assigned to the variable. you are already saw some of the common data types in Python.
Here you can see list of python data type .With the help of data type you can create a program in python.
We can see below example :-
x = "Hello Developer" datatype = string
x = 30 datatype =int
x = 30.5 datatype =float
x = 1j complex
x = ["apple", "banana", "mango"] datatype =list
x = ("mango", "banana", "cherry") datatype =tuple
x = range(8) datatype =range
x = {"name" : "shubham", "age" : 36} datatype =dict
x = {"mango", "banana", "cherry"} datatype =set
x = frozenset({"mango", "banana", "cherry"}) datatype =frozenset
x = True datatype =bool
x = b"Hello developer" datatype = bytes
x = bytearray(5) datatype = bytearray
x = memoryview(bytes(5)) datatype = memoryview
x = None datatype = NoneType