Python DataTypes
Python datatypes are Numbers, Strings, Lists, Tuples and Dictionary. Python has the good memory management support. In this tutorial we will learn about Overview of different Types of Python Data Type. Techtuts provides an example along with concepts. You have to workout the example programs for good and well.
Python Data types
Python has different types of data types. Python has the five primary datatypes. The data type of python are as follows.
- Number
- String
- List
- Tuple
- Dictionary
Python Numbers
Python number datatype is used for numeric values. Number object is created when you give the numeric value to the variables
Ex:-
vara = 1
varb = 1234
Python number datatype can be used for the following numerical types
- Int
- Float
- Long
- Complex Numbers
Python String
String is represented as Collection of characters placed within the Quotes( " ) or single quote( ' ). We can use ( + ) for Concatenate and (*) for string repeat print.
Ex:-
varStr='abc'
varStr="abc"
Python List
It is a python compound data types, A list consists the items separated by comma(,) and enclosed within square Brackets ( [] ). We can add different data type of items in the list items. we can assign Int, Float ,string etc as items of the list.
Ex:-
varList = ['abc', 123, 234.90]
Python Tuples
It is another data type like as list. Instead of square Brackets([]), it enclosed with parentheses ( () ). In tuples we cannot be updated. It is known as read only list
Ex:-
varTuple = ( 'abc', 123, 234.90 )
Python Dictionary
Python dictionaries are hash table type. it has the key and value. we can specify any python data type within the dictionary
This datatype is enclosed within the curly phrases ( {} ) and get the value by using square brackets ( [] ).
Ex:-
varDictionay ={'name':'jhone', 'age':'25', 'dob':'2021-06-13'}
we can use keys() to get all the keys and values() to get all values of dictionary
Ex:-
varDictionary.keys() # Print all the keys
varDictionary.values() # Print all the values