Different common built in data types in python with sequence example :
• Text Type:- Str(String)
1)String is a python sequence of character.
2)It is a derived data type.
Also read : comprehension in python
• Numeric Types:- int, float, complex
1)Int is a integer. It is used to convert a specified value into an integer number.
2)Float is a data type used to return a floating point number from a number or string.
3)Complex is used to convert number or string into complex number.
• Sequence Types:-List,Tuple,Range
1)List is a collection of object. List are ordered in type. It contain arbitrary objects. Elements of a list can accessed by an index. List contain other list as sublists. Lists are in variable in size. Lists are mutable that’s why list can be changed.
2)Tuple is an immutable list. Once a tuple is created it cannot be changed. Tuple is analogously to lists. Tuples are faster as compare to list.to protect data from accidental changes use tuples instead of using list. Tuples can be used as keys in dictionaries while list can’t be used in dictionaries.
3)In Range function elements can be accessed using index values.
Also see : Generator in python
• Mapping Types:-Dict
1)Dict is a Dictionary . It is mutable.keys of dict are arbitrary.
• Set Types:-Set,Frozenset
1)Set is a mutable.add(),remove() like these operations performs on set but it is not possible to do these operations on frozenset. Set do not record element position. Set do not support indexing,slicing, or any other sequence related operations.
2)Frozenset is a immutable
• Boolean Type:-bool
Bool is used to represent the truth value of an expression.
In boolean type there are only two possible values True or False.
• Binary Types:-Bytes,bytearray,memoryview
1)Byte and Byte arrays are used to manipulate binary data in python.These are supported by protocol named memoryview.
2)Memoryview can access the memory of other binary object without copying actual data.
Also see : prime factor in python
In this article we saw common built in data types in python with sequence example so about this section you have any query then free to ask me
Name of Intern Who share this Task :