Ad Code

Responsive Advertisement

DATA TYPES IN PYTHON | Learn Python for Free

DATA TYPES IN PYTHON

Hey guys welcome again, and today we will learn what are the data types in Python 3, data types categories, immutable data types, mutable data types, and Conversion of  data types. We are also providing you some learning tips which will help you to learn better.






Important to Know!


Note in this page are given purple color    .
Learning tip in this page are given in red color    .
Code in this page are given grey color    .

DATA TYPES IN PYTHON


What are DATA TYPES ?

Datatypes in Python are the type of the data which are stored in a variable.

Data types are classified in the following types which I will explain you in a simple way in detail.

So so let's see the types of data in Python-:

  • Number Type
  • None type
  • Sequence type
  • Set type
  • Mapping type

First I want you to see the given table of data types



Let me explain you all the data types in Python briefly-:

Numeric Type -:



Numeric Type data store the numeric value, like 100,100.9, 200.99 etc.

Numbers in Python are classified into three types-:

  • Integer
  • Floating point number
  • Complex numbers


Let us check the the different type of numeric type in Python-:

Integers-: 


Integers are the positive and negative values which do not have decimal point in it.
Learning tip -: an integer in Python can be of any length.

For example-: 122, 133, 436 etc. 

Boolean came under integers.

Boolean-:

Boolean data type represent one of the two possible values eighter true or false.

Learning tip-: A Boolean true value is non zero, non null, non empty.

Floating point Numbers-:


Floating point numbers  are the positive and negative numbers which have decimal point in it.

Learning tip-:the fractional part of a floating point number can also be 0 (zero).

For example-: 133.0, 123.8, 546.2 etc.

Complex Numbers-:


Complex numbers are the combination of real and imaginary, which are present in the form of  x+yj.
Where x is real and y is imaginary.

Note-: x and y are always the floating point integer.

For example -: 

2+5j, 4-3j etc.

In Python -:

>>> x=2+5j
>>> print(x.real,x.imag)
2.0 5.0

None Type-:


What is None in Python?


This is a special data type with a single value and it is used to signify the absence of value evaluating to false in a situation.

For example-:

>>> value1=20
>>> value2=None
>>> value1
20
>>> value2
>>> 


Sequence Type -:



Under Sequence Type there comes-:

  • String
  • Tuples
  • Lists

String-:

String is represented by (str), which is a sequence of characters that can be a combination of numbers letters and special characters enclosed within quotation marks.

Quotation mark ( " " ) define the starting and ending of string which are not printed on the screen.

For Example-:

print("Hello World")


Sets-:



A set in Python is unordered collection which is unindexed, and they are written with curly brackets in Python.

For example-:

set={"hello","world","welcome"}

Mapping-:

Dictionary-:



Python dictionary is an unordered collection of items for each item is a key value pair.

{ "Python" : "Dictionaries"}

for any question comment in the comment box.

Post a Comment

0 Comments