What are Standard Data Types in Python 3?

PythonServer Side ProgrammingProgramming

Standard data types of Python include numeric data types, sequence types and dictionary which is a collection of key-value pairs.

Objects of numeric data types are either integers, floats or complex numbers. Integers are whole numbers, whereas floats have a fractional part. Complex number has two components, real and imaginary part. A float number multiplied by j which is an imaginary value equalling square root of -1 forms the imaginary part of complex number.

Python sequences include strings, lists and tuples. String is a sequence of any characters put in single, double or triple quotes. List is an ordered collection of items enclosed in square brackets. Tuple is also an ordered but immutable sequence of items enclosed in parentheses.

Dictionary is an unordered collection of key and value pairs. Key can be of any immutable type such as number, string or tuple and must not repeat in a dictionary object.

10, -10 -> integers
1.55, 0.005 -> float
2+3j, 5.6-1.5j ->complex
‘hello’, “how are you” ->string
[1,2,3,4] -> list
(1,2,3,4) ->tuple
{‘a’:1, ‘b’:2, ‘c’:3} ->dictionary
raja
Published on 30-Dec-2017 18:37:46
Advertisements