Wednesday 11 March 2020

Datatypes in Python- Lecture 1


Data Types


Data Type represent the type of data present inside a variable.
In Python we are not required to specify the type explicitly. Based on value provided, the type will be assigned automatically.


Hence Python is Dynamically Typed Language.


Python contains the following inbuilt data types:


1. int  : to store integer values
2. float : to store floating point values and exponential values
3. complex : to store values in the form of a+bj , basically used to store scientific values
4. bool : to store Boolean values True or False
5. str : to store sequence of characters

The above five data types are Fundamental Data types and all of them are Immutable

6. bytes: to store sequence of numbers in range of 0-256, bytes are Immutable
7. bytearray : Mutable version of bytes is bytearray, rest it is same as bytes
8. range:  to store sequence of numbers of specified range. Elements of range are also immutable
9. list: to store multiple heterogenous values in one object
where order of insertion is preserved and
 duplicates are allowed.
lists are Mutable
10. tuple : Immutable version of list is tuple, rest it is same as list
11. set : to store multiple heterogenous values in one object where order of insertion is NOT preserved and
duplicates are not allowed.
Sets are Mutable
12. frozenset :  Mutable version of set
13. dict : to store key- values
14. None means nothing at all



Note: Python contains several inbuilt functions

1.type() to check the type of variable

2. id() to get address of object

3. print() to print the value

In Python everything is object.


For details please go through the above video

 

No comments:

Post a Comment