#Data Type:
"""
- It define the format & storage size of particular data
- On the basis of the definition, data type are classified as:
- Numeric Data
- Integer
- Float (decimal values)
- Complex Number (combination of real & Img.)
- Sequence Data
- List
- Tuple
- String
- Mapping Data
- Dictionary
- Set
- Boolean
"""
#type() function:
"""
- It return the type of object that hold value.
"""
a=10.7
print(type(a))
#id() function
"""
- It return the address of variable/object that hold data
"""
print(id(a))
#Integer
"""
- This data type used to represent +ve, -ve & zero numeric data
- Do not include decimal(float) value
- In python there is no limit of storing data of fixed length
"""
a=10
print(type(a))
#Float (decimal values)
"""
- This data type used to represent +ve, -ve & zero data
- including decimal(float) value
- In python there is no limit of storing data of fixed length
"""
a=10.7
b=12.5
c=10.0
print(type(a))
print(type(b))
print(type(c))
#Complex Number
"""
- This is same as mathematical data complex number
- Syntax
a+bj
"""
a=5+6j
print(type(a))
#LIST
"""
- It is mutable (changable) sequence data type.
- It can store multiple values of same kind or different kind.
- It represented by square bracket []
- It follow indexing pattern, It indexing are:
from left to right- 0,1,2....
from right to left- -1,-2,-3....
"""
L=[]
print(type(L))
M=[10,12,14,16,18,20]
N=["Lucky",18,"XI-A",90.5]
print(type(M))
print(type(N))
M[2]=100
print(type(M))
#indexing
# 0 1 2 3 4 5
M=[10,12,14,16,18,20]
# -6 -5 -4 -3 -2 -1
print(M[1])
print(M[-5])
#TUPLE
"""
- It is Immutable (not changable) sequence data type.
- It can store multiple values of same kind or different kind.
- It represented by paranthesis bracket ()
- It follow indexing pattern, It indexing are:
from left to right- 0,1,2....
from right to left- -1,-2,-3....
"""
L=()
print(type(L))
M=(10,12,14,16,18,20)
N=("Lucky",18,"XI-A",90.5)
print(type(M))
print(type(N))
#STRING
"""
- It is array of characters.
- It is also immutable.
- It follow indexing same as list
- It store the values between pair of Triple,double
or single qoutes.
"""
A="Manthan"
B='Manthan'
C='''Manthan'''
print(type(A))
print(type(B))
print(type(C))
#Mapping Data - Dictionary
"""
- It is ordered collection of items, seperated by comma
- Items are ordered pair of Key & Values seperated
by colon :
- Keys in Dictionary behave as index in list/tuple.
- It is represented by curly brackets {}
"""
D={}
print(type(D))
T={1:"Aditya",2:"Bhuvan",3:"Nishant"}
print(type(T))
print(len(T))
#len() method used to find length of dictionary
#SET
"""
- It is unodered collection of elements/objects.
- It always contain distinct values.
- It is also represented by curly bracket {}.
"""
#How to create empty set
D=set()
print(type(D))
print(D)
T={10,20,30,10,40,30}
print(T)
print(type(T))
#Boolean Data Type:
"""
- It is built-in data type, used to represent
truth value of expressions.
- For Example:
a>b -> it may return True or False depending
on value of a & b
"""
a=10
b=6
print(a>b)
print(not True)
print(True or False)
print(False or False)
print(True and False)
print(True and True)
print(not True and False)
#input() function :
"""
- This function used to take input from user.
- This function take string input by default.
- To convert string input data to int or float
use concept of typecasting
"""
a=input("Enter value of a:")
b=input("Enter value of b:")
c=a+b
print("Value of c= ",c)
#Typecasting- str->int
a=int(input("Enter value of a:"))
b=int(input("Enter value of b:"))
c=a+b
print("Value of c= ",c)
#Typecasting- str->float
a=float(input("Enter value of a:"))
b=float(input("Enter value of b:"))
c=a+b
print("Value of c= ",c)
#Type conversion:
a=1
b=2.3
c=a+b
print("value of c: ",c)