You are currently viewing DATA TYPE IN PYTHON
data-type-in-python-bittutech

DATA TYPE IN PYTHON

Hello!! dear visitors, Welcome again in this domain on bittutech.com. I hope you all are very excited to read this blog post. Please give me your golden feedback to enhance by blogging skills.

More links -:

Today’s blog post is fully dedicated to Types of data or data type  in Python Programming Languages. 

So Let’s dive into the python pool.

Data Type

Data of can be many types e.g., character, integer, real, strings etc. Anything enclosed in quotes represents string data in Python. Numbers without fractions represents integer data in Python. Numbers with fractions represents real data or float data and TRUE and FALSE represents Boolean data.

Python offers following built-in core data types–:

Numbers

As it is clear by the name, the number data type are used to store numeric values in Python.

i). Integers:–

Integers are whole numbers such as 5, 10, 20, 30 etc. They have no fractional parts.

There are two types of integers in Python–:

NOTE–: The two objects representing the value False and True are the only boolean objects in Python

ii). Floating point Numbers–:

A number having fractional parts is Floating point Numbers.

Floating point Numbers have two advantages over integer–:

And Floating point Numbers have one disadvantage also –:

NOTE–: In Python Floating point Numbers represent machine level double precision floating point numbers (15 digit precision).

iii). Complex Numbers–:

A Complex Number is the form ‘A + B i’ where ‘ i ‘ is the imaginary number, equal to the square root of -1 i.e., √- 1, that is i²= -1.

The ranges of Python Numbers -:

Strings

Strings in Python are arrays of bytes representing unicode characters.:-

String as a sequence of Characters

A Python String is a sequence of characters and each character can be individually accessed using its index.

NOTE–: The str( ) function converts a value to String.

NOTE–: Length of string variable can be determined using function Len(<string>).

The index (also called subscript sometimes) is the numbered position of a letter in the string. In Python, indices begin 0 onwards in the forward direction and -1, -2…. in the backward direction.

Lists and Tuples

The lists and tuples are Python’s compound data types. Lists can be changed or modified (i.e., mutable) but Tuples cannot be changed or modified(i.e., immutable).

Let’s talk one by one–:

Lists–:

A List in Python represents a list of comma-seperated values of any datatype between square brackets [ ].

For Example–:

A= [1,2,3,4,5]
B= ['a','e','i','o','u']

NOTE–: First item of the list is internally numbered as 0, second item of the list as 1, third item of the list as 2 and so on.

Tuples–:

Tuples are represented as group of comma-separated values of any data type within parentheses.

For Example–:

P= (1,2,3,4,5,6)
S= (7,8,9,a,b,c)

NOTE–: Values of type list are mutable i.e., changeable ( one can change )/ add/ delete a list’s elements. But the values of type tuple are immutable i.e., non changeable (one cannot make change to a tuple).

Sets

Sets are also similar to lists that can store multiple values.

Differences are–:

Dictionary

The dictionary is an unordered set of comma-separated key:value pairs, within { }.

For Example–:

Vowels={'a':1,'e':2,'i':3,'o':4,'u':5}

Here, ‘a’, ‘e’, ‘i’, ‘o’ and ‘u’ are key of dictionary vowels: 1,2,3,4,5 are values for these keys respectively.

Following figure summarizes the core data types of Python.

Last Words:I hope you all are very happy and enjoy this blog post and also very excited to get something new. Don’t worry, we will meet very soon with a new and interesting blog post that absolutely enhance your technical skills and knowledge.

Share post

Prajjwal Singh

Tech Blogger || Web developer || Computer Networking Enthusiast || Microsoft SQL Database Management Expert || Software Debugger || Learned DOS OS Structure

Leave a Reply