Basics Of Python -2

Photo by Chris Ried on Unsplash

Basics Of Python -2

DAY 2:

In this blog, you will get to know about the basic data types of python.

DATA TYPES
Data types are nothing but the classification of the data items in python. Like by using data types, we get to know about the class of that particular data.

There are different types of in-built data types in python. We will discuss it with examples.

DATA TYPES IN PYTHON:

  1. Numeric

  2. Boolean

  3. Sequential

  4. Dictionary

  5. Set

  1. Numeric -

Numeric data types in python define a numerical class.

  • Integer

  • Float

  • Complex

Integer

n=45
print(type(n))

output :

Float

n=5.01
print(type(n))

output :

Complex

n=5.01+1j
print(type(n))

output :

These are the numeric data types in python.


  1. Boolean

Boolean data types are whether the object is true or false.

print(type(True))

output :

print(type(False))

output:

It is very important, to write the first letter of "True" in capital "T", and "False" in capital "F", otherwise you may get an error.

  1. Sequential

Sequential data types are the ordered collection of data items.

  • String

  • List

  • Tuple


String

  • Collection of characters
s=str(input("Enter the name : "))
print(s)
print(type(s))

output :

Enter the name : Priya
Priya
<class 'str'>

List

  • Collection of data
l=[2,4,5,2]
print(l)
print(type(l))

output :

Tuple

  • ordered collection of data
t=(4,6,2,4)
print(t)
print(type(t))

output :


  1. Dictionary

  • An unordered collection of data has a "Key" and "Value", the key is immutable whereas the value is mutable.
l={1:'Me',2:'You',3:'Us'}
print(l)
print(type(l))

output :


  1. Set

  • The set is an unordered collection of data that is mutable, iterable and has no duplicate items.

      l={2,3,4,2,3,6,7,8,4}
      print(l)
      print(type(l))
    

output :

These are the data types ,or in-built data types of python programming.

For your reference :

DATA TYPESIMMUTABLEMUTABLE
Numeric
List
String
Dictionary
Tuple
Set

In my next blog ,you will get to know more about this data types in details.

Thank you.