Python Language Skill UP
  • Twitter
  • Facebook
  • Snapchat
  • Instagram

Python Data Type

data types in python A data type is a numbers,words,measurements,observations or observations that a variable or object can hold in computer programming.
Data Any Variable Declared in python programming has a data type according their type of observed values. Every data type in Python language needs storage or amount of memory. And specific operation can be performed on it.
Once a value assigned to a variable It can store any kind of data like integer, character, floating, double, boolean, complex, string,list,tupple etc. The data type is a group of data with values having fixed values, meaning as well as its characteristics.
Python is dynamically typed language hence do not need to declare data type is automatically detects data type of a variable depending upon value assigned .
e.g . a=25
here a is assigned value 25 and its data type is <class,'int' >.

Data Type: “ Data Type in Python programming specifies what kind of values does variable store or hold and the kind of operation performs on the values”.
Data Type describes chaacteristics of variable.
Python is object oriented, hence everything in python is object .Datatypes in python are classes and variables are instances of the class.
Python provides type() function to check the data type of a variable.

Data Types in Python: :

Python has following built in data types .
1. Numberic.
2. Sequence.
3. Dictionary.
4. Boolean.
5. Set.

1. Numeric Data type:

Numeric data types are the numbers stored in python variable. Numeric or number data types in python are grouped on their numeric values. The exact Type of Numeric or Number Data types in python are
a. Integer:
In Python Integers are hole number either zero, positive or negative numbers without fractional part in it , having unlimited precision.
e.g >>>a=6
>>>a=456577
>>>a=6700000000000000000000000000000000000000000000000
b.Float:
Float Data type in Python are numbers that can be a positive and negative real numbers with a fractional part denoted by the decimal symbol . or the scientific notation E or e,
e.g. 1234.56, 3.142, -1.55, 0.23.
>>> g=9.8
>>> g
9.8
>>> type(g)
<class 'float'>
c.Complex:
Complex data type is one of the inbuilt data type in python. Complex data type have two values. The value is the real part of a number and second one is the imaginary part of the complex number.
In complex number Imaginary part is denoted by i
And real part is denoted by j.
e.g 3i+4j.
>>>c=1+2j
>>>type(j)
<class ‘complex’>

# e.g Python script To Demonstrate Numeric /Numbber Data Type in Python
a = 6       #int
print(a)
print(type(a))
g = 9.8       #float
print(g)
print(type(g))
c = 1+2j       #complex
print(c)
print(type(c))

output:
6
<class,’int’>
9.8
<class,’float’>
1+2j
<class,’complex’>


2. Sequence Data type:

Sequence data type store is a container that store different data values in organised or sequential ordered form.
Sequence Data Types in Python has Three sub types
i. String:
A string is defined as a collection of one or more characters.
It iscan be put in single quotes or double quotes or triple quotes i.e (' ') , (" ") or (' ' ' ' ' ') .
for eg: s="www.python.org" .
e.g
s=”Wellcome”
print(s)
print(type(s))
output:
welcome
<class,’str’>.
ii. List:
List is a group or collection of heterogeneous data type. It hold any kind of data.
L=[1,”one’,2.5]
Print(L)
Print(type(L))
[1,”one’,2.5]
<class,’list’ >.
iii. Tuple :
Tuple is a ordered collection of a any data values which cannot be changed means Tuples are immutable. once a tuple is created whose items cannot be modified.
Tuples created with ().
T=(1,2,”three”)
print(T)
print(type(T))
Output:
(1,2,”three”)
<class,’tuple’ >

3.Dictionary:

Dictionary in python is an ordered collection of data items. Items in dictionary is changeable and cannot allow duplicates data items. It has key:value pair which is separated by a colon :, and all keys are separated by a ‘,’.

eg :
mydict={'age':25, 'b':2, 'three':3}
y = {"name" : "python", "age" : 40}      #dict
print(y)
print(type(mydict))
{'name': 'python', 'age': 40}
< class 'dict' >

4.Boolean:

Booleans data type is one of the inbuilt data type in python used to represent one of two values: True or False.
a = True #bool
print(a)
print(type(a))
True
<class 'bool'>

5.Set :

Set is an unordered ,unique collection of data types that are mutable (change)and has distinct elements.
eg: s={1,2,3,4,5}

y = {"Python", "C", "CPP"} #set
print(y)
print(type(y))

output
{'Python', 'C', 'CPP'}
<class 'set'>



Next topic Operators and Expressions

Python

  • Home
  • History of Python
  • Applications of Python
  • Introduction To Python
    • What is Python.
    • Character Set
    • Tokens in Python
    • Python Execution Mode
    • Variable And Identifiers
    • Data Types in Python
    • Operators And Expressions
    • Constants in Python
    • Assignment Statement
    • Input / Output in Python
    • Simple 'Python' Scripts
    • Namespace in 'Python'
    • Assignments
  • Operators in Python
    • Arithmetic Operators
    • Assignment Operators
    • Shorthand Assignment Operators
    • Relational Operators
    • Logical Operators
    • Bitwise Operators
    • Special Operators
    • Assignments
  • Input Output in Python
    • Accept Input
    • Output Formating
  • Conditional Statement
    • Decision Making
    • if Statement
    • IF-ELSE STATEMENT
    • IF-ELSE LADDER
    • NESTED IF-ELSE
    • short hand IF-ELSE
    • Assignments
  • Loops
    • Introduction to Loops
    • While Loop
    • Nested While Loop
    • while loop assignments
    • for Loop
    • For loop examples
    • Nested for loop
    • Nested for loop examples
    • Infinite while Loops
    • Infinite for Loops
    • break,continue and else in Loops
    • Difference between for and while loop
    • for each loop
    • for each Assignments
  • List
    • List in Python
    • Access List elements
    • List functions
    • Iterate(loop)List
    • List comprehension
    • List Assignments
  • Tuple
    • Tuple in Python
    • Access tuple elements
    • tuple functions
    • Iterate(loop)tuple
    • Unpack Tuple
    • tuple comprehension
    • tuple Assignments
  • set
    • Set in Python
    • Access set elements
    • set Methods
    • Iterate(loop)set
    • Pack/Unpack Tuple
    • tuple comprehension
    • set Assignments
    • Set comprehension
  • Dictionary
    • Dictionary
    • Access dictionary Items
    • dictionary method
    • Iterate(loop)Dictionary
    • formating Dictionaries
    • Nested Dictionaries
    • dictionary comprehension
    • dictionary Assignments
  • Diff list tuple set dictionary
    • list vs tuple
    • list vs set
    • list vs dictionary
    • tuple vs set
    • tuple vs dictionary
    • dictionary vs set
  • Exception
    • Error vs Exception
    • Exception Handling
    • Types of Exception
    • User Defined Exception
    • Logging Exception
    • assignments
  • Functions
    • Introduction
    • Modular Programming
    • Type of functions
    • Inbuilt Function
    • Need For User-Defined Function
    • Elements Of User Defined Function
    • Function Argument
    • Nesting of Function
    • Recursion
    • Global Local and Non Local
    • Python Lambda Functions
    • Assignments
  • Python Module
    • introduction to module
    • Inbuilt Module in Python
    • User Defined Module in Python
    • Assignments
  • File Handling
    • Introduction to files
    • Create File
    • Read files
    • Write to File
    • Rename File
    • Copy File
    • Move file
    • List files in Directory
    • Binary files
    • Zipping and unzipping files
    • Assignments
  • Strings
    • Basics of Strings
    • String Special Operator
    • String Formatting operator
    • String methods
  • Regular Expressions
  • Python OOPS
    • Basics of Object Oriented
    • What are Classes and Objects?
    • Creating Class and Object
    • Diff object oriented and procedural oriented programming
    • difference between classes and object
    • Constructors
    • destructor
    • built class methods and attributes
    • class and instance variable
    • Inheritance in Python
    • Single Inheritance
    • Multiple Inheritance
    • Multilevel inheritance
    • Hierarchical Inheritance
    • Hybrid Inheritance
    • Abstraction
    • Method Overriding
    • Abstract Method
    • Interfaces in python
    • Abstract class vs interface
    • Public in python
    • Private in python
    • Protected in python
    • Overloading Vs Overriding
    • inheritance vs composition
    • Encapsulation
    • Polymorphism
    • inner classes
    • Opps Assignments
  • Mysql database in python
    • introduction
    • DBMS vs file
    • connecting to database
  • Mysql database Operation
    • Select
    • Operators
    • DDL
    • DML
    • subqueries
    • joins
    • Case study
  • Graphics
  • Iterator in python
  • Generator in python
  • decorator in python
  • Threads in Python
    • introduction
    • process and threads
    • concurrent programming and GIL
    • Uses of threads
    • creating Threads
    • Single tasking
    • multi tasking
    • thread synchronization
  • Frequently Asked Interview Questions (FAQ)
  • Case Studies
  • Multiple Choice Questions

Get in touch

  • tech2dsm@gmail.com

© tech2dsm. All rights reserved.