Home / Computer Science / Python / Basic Data Types in Python

Basic Data Types in Python

Python is essential data science/data analytics, Most of the people are doing online course in data science python/data analytics course. Few companies are offering internships in Python and data analytics.

Here we discuss about Basic data types in Python.

Like other programming languages python has multiple data types to handle programming scenarios.

These data types are builtin data types. Basic data types available in Python are listed below.

  1. Boolean
  2. Integer
  3. Complex
  4. Float
  5. String

Data TypeSymbolNotesValue Range

Boolean bool Boolean data type uses when we represent conditional statements or logic statements like true or false True or False
Integer int Integer data type represents both positive and negative data type values all integers (+ve and -ve)or set ‘Z
Complex complex If you want to deal with complex numbers such contains real and imaginary parts (x + iy) where x is real and iy is imaginary part All complex number in the form of x + iy
Float float A number which contains decimals are declared as floating point numbers All decimal numbers
String str All the string which are enclosed in the single ” ‘ ” quote or double ” ” ” quotes are treated as strings, even if the number is present in these quotes treated as string. Strings or a sequence of characters

The above table shows basic data types and its symbols.

In my previous post, you may learn how to find the data type of the variable.

Here is the demo program for your reference.

# -*- coding: utf-8 -*-
Created on Tue Oct 29 00:08:28 2019

@author: GSK
a = “Hello Python”

#To display value of a:

#to know the data type of a:

b = 52

#To display value of b:

#to know the data type of b:

c = 20.5

#To display value of c:

#to know the data type of c:

d = complex(2,1)

#To display value of d:

#to know the data type of d:

d1 = 1 + 2j

#To display value of d1:

#to know the data type of d:

e = True

#To display value of e:

#To display value of e:

Out put of the above program is:

Hello Python
<class ‘str’>
<class ‘int’>
<class ‘float’>
<class ‘complex’>
<class ‘complex’>
<class ‘bool’>

About santosh G

Hi, i am Santosh Gadagamma, a tutor in Software Engineering and an enthusiast for sharing knowledge in Computer Science and other domains. I developed this site to share knowledge to all the aspirants of technologies like, Java, C/C++, DBMS/RDBMS, Bootstrap, Big Data, Javascript, Android, Spring, Hibernate, Struts and all levels of software project design, development, deployment, and maintenance. As a programmer I believe that, “The world now needs computers to function.” Hope, this site guides you as a learning tool towards greater heights. I believe that Education has no end points and i wish to learn more in the process of teaching you….,

Check Also

Key words in Python

Generally, every programming language has syntax like the same python has its own syntax, key …