How many Cyber of Data types used in Python . Write their name with example.
Answers
Answer:
The classification or categorization of data objects is known as data types. The built-in data types in Python are as follows :- Number, dictionary, boolean, set, sequence type etc.
Explanation:
1. Number data type is used to store numerical values. Number is of immutable type means value of its object cannot be changed. Types of number datatype are:-
Integer & Long
Float/floating point
Complex
2. Sequence datatype is an ordered collection of items, indexed by positive integers. It can be of both mutable and non-mutable data types. Types of sequence data type are :-
Strings
Lists
Tuples.
3. Sets :- It in an unordered collection of objects used to store number of items in single variable. Sets are immutable and only immutable objects can be a part of set object.
Example S1= Set ({'1', "python", "java"])
4. Mapping :- It is an unordered collection of objects and mutable. Dictionaries falls under mapping.
Dictionaries can store any number of python objects containing of key – value pairs, which are accessed using key. Dictionary is enclosed in curly brackets.
Example d = {1 : ‘hello’, 2 : 'hi’, 3 : ‘hey }