Skip to content

Latest commit

 

History

History

datatypes

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

DATATYPES

The data type of a value is an attribute that tells what kind of data that value can have. Data types define particular characteristics of data used in software programs and inform the compilers about predefined attributes required by specific variables or associated data objects.

Use Of DataTypes

Data types are basically used for two reasons:

  • Knowing the type of data used for processing/returning. This helps both the programmer(not necessarily) and compiler use the values in the right form. Also the programmer can choose the data type according to the requirements like precision, integer values, range and sign.

  • Memory allocation: Every data type has a memory size associated with it. So proper utilisation of memory can be done when suitable data types are used.

Available DataTypes In Python

There are various data types in Python. Some of the important types are listed below:

  • Numbers

    • Integers, floating point numbers and complex numbers falls under Python numbers category. They are defined as int, float and complex class in Python.
  • List

    • List is an ordered sequence of items. It is one of the most used datatype in Python and is very flexible. All the items in a list do not need to be of the same type.
  • Tuple

    • Tuple is an ordered sequence of items same as list.The only difference is that tuples are immutable. Tuples once created cannot be modified.
  • Strings

    • String is sequence of Unicode characters. We can use single quotes or double quotes to represent strings. Multi-line strings can be denoted using triple quotes, ''' or """.
  • Sets

    • Set is an unordered collection of unique items. Set is defined by values separated by comma inside braces { }. Items in a set are not ordered.
  • Dictionary

    • Dictionary is an unordered collection of key-value pairs. It is generally used when we have a huge amount of data. Dictionaries are optimized for retrieving data. We must know the key to retrieve the value.

You can check out more examples here.

For more information on DataTypes: You can check out more examples here.

For more information on DataTypes: