Skip to main content

Python Data Types


Data Type in Python:-

Python data types are different in some aspects from other programming languages. 

It is simple to understand and easy to use. Because Python is interpreted programming language and Python interpreter can determine which type of data are storing, so no need to define the data type of memory location.

Every value in Python has a datatype. Since everything is an object in Python programming, data types are actually classes and variables are instance (object) of these classes.

The data type determines:-

·         The possible values for that type.
·         The operations that can be done with that values.
·         Conveys the meaning of data.
·         The way values of that type can be stored.

*There are various data types in Python. Some of the important types are listed below.
Python Numbers:-
Integers, floating point numbers and complex numbers falls under Python numbers category.
They are defined as intfloat and complex class in Python.


We can use the type() function to know which class a variable or a value belongs to and the isinstance() function to check if an object belongs to a particular class.
 Integers can be of any length, it is only limited by the memory available.
A floating point number is accurate up to 15 decimal places. Integer and floating points are separated by decimal points. 1 is integer, 1.0 is floating point number.
Complex numbers are written in the form, x + yj, where x is the real part and y is the imaginary part.
Examples:-
a = 5
print(a, "is of type", type(a))

a = 2.0
print(a, "is of type", type(a))

a = 1+2j
print(a, "is complex number?", isinstance(1+2j,complex)) 










Comments

Popular posts from this blog

Python keyword and identifiers

Python Keywords Keywords are the reserved words in Python. We cannot use a keyword as  variable name ,  function  name or any other identifier. They are used to define the syntax and structure of the Python language. In Python, keywords are case sensitive. There are 33 keywords in Python 3.3. This number can vary slightly in course of time. All the keywords except  True ,  False  and  None  are in lowercase and they must be written as it is. The list of all the keywords are given below. Keywords in python programming language True False None and as assert break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield Python Identifiers Identifier is the name given to entities like class, functions, variables etc. in Python. It helps differentiating one entity from another. Rules for writing identi...

Python Introduction

What is Python? https://drive.google.com/file/d/12anPuRDTNSLdI6JhzNtRRbKeHnOfnJy3/view?usp=drivesdk Python is a popular programming language. It was created in 1991 by Guido van Rossum. It is used for: web development (server-side), software development, mathematics, system scripting. Python is a widely used general-purpose, high level programming language. It was initially designed by  Guido van Rossum  in 1991  and developed by Python Software Foundation.  It was mainly developed for emphasis on code readability, and its syntax allows programmers to express concepts in fewer lines of code. Python is a programming language that lets you work quickly and integrate systems more efficiently. The Python  IDLE  (Integrated Development Environment)  executes instructions one line at a time.  This also lets us use it as a calculator. There are two major Python versions-  Python 2 and Python 3 . Both are quite d...