Python – Data types – Day 3


Data Types

We come across various types of day in the real world. Basically, we invented it to describe any unit of datum.

in the same way, programming languages are designed for various purposes and have different data types to process the users input.

For example, FORTRAN (Formula Translation) is a computer programming language that is used for scientific data processing.

COBOL (Common Business Oriented Language) – Programming language for business data processing.

these two notable legendary programming languages that have rich data types to handle various application data.

Likewise, Python is capable of handling different type of data for today’s modern applications.

  1. numeric – integer, float, complex
  2. boolean – values are True, False
  3. set – {}, it is an unordered, unindexed and deduplicated data collection in a single variable.
  4. mapping – {“key”:”value”}, Dictionary data store with key-value pair.
  5. sequence – string, list is the collection storage of similar data type. tuple contains different types of data.

data types are grouped into mutable and immutable. mutable allows the program to update the value in the existing memory and immutable does not allow the program to update the value instead it created new memory and old memory will be given away then freed by garbage collection.

examples:

interger

a = 1

floating point

b = 1.5

complex number

c = complex(a + b)

boolean

f = True

set

A = {1,2,3,4,True, False, 4,3,2,1}

dictionary

d = {“name”:”dog”,”job”:”guard”}

sequence – can retrieve value using the index [1…n]

string

e = “elephant”

list

f = [‘f’,’u’,’n’]

tuple

g = (1,3,5,’odd’,’natural’, True)

you can view the output of the variables using print() function

Python interactive shell

Leave a comment