Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

Data Type in Python, What is Data Type in Python

The data type is used to provide a pattern, size, and memory allocation of data using variable, constant, and method.

Python uses data type internally in the program, no need to write a data type declaration in the program because python provides flexibility to the identifier to contain multiple types of data using a single name identifier.


a=10

a= "hello"

a= True


Type of Data type:-

Primitive Type:-  it is the primary data type of Python that is common for all programming languages.

 


1 int :-       a=10

2 float:-    a=12.34

3 String:-  Collection of Char's


s= "data"           HTML Content will be rendered in double quote,. and it is used to declare outer String

s= 'data'             Html content will not be rendered content and it is for inner string

s= """data"""    it support paragraph pattern or multiline statements

''' comment '''     multiline comment


4 boolean:-

it is used to create checkpoint or true|false value in the variable

by default, if statement, loop statement return a boolean value


b = True

b= False


boolean type basically used on a conditional statement, loop statement


Derived Data type:-


this type of data type is specially created for Python Script.


1  LIST:-  it is used to contain a set of elements using an index from 0 to size-1 whose value can be change

2 TUPLE:-  it is used to contain a set of elements using the index value pair whose value can not be changed

3 DICTIONARY:-  it is used to contain a set of elements using key: value pair 


4 Set:-  It is used to display elements randomly.


5 DATETIME:-  it is used to contain current data and time 


6 Class:-  it is used to create User-define type


7 Complex:-  it is used to contain a complex number


a = 2+3j    j means iota 


........................................................................................................

Predefine function in Python for Data type


type():-   it is used to represent data type of any identifier in Python


a=10
print(type(a))
a=20.2
print(type(a))
a=2+3j
print(type(a))
a=(10,20)
print(type(a))
a=[10,20]
print(type(a))
a={'a':10,'b':20}
print(type(a))
a=True
print(type(a))
a='hello'
print(type(a))
a="hello"
print(type(a))
a="""hello"""
print(type(a))

int():-  this method is used to convert numeric String to integer

a= "123" 
a = int(a)  #123

float():-  this method is used to convert numeric float String or integer to float

a=12
a = float(12)  #12.0

a= "12.34"
a=float(a)  #12.34

str():-  this method is used to convert int, float type value to String type

a= 12
b=str(a)  #"12"

b = str(12.34)  #"12.34"


Q WAP to convert temperature from Celsius to Fahrenheit?

Q WAP to perform multiplication of a complex number using complex data type?

Q WAP to evaluate the middle number in three-digit numbers based on order ?


a= 132   #2

a=456  #5

a = 546  #5

Q WAP to print data in the single quote and double quote

 "Welcome in SCS"
 'Welcome in Python'
 '\n hello \n"










12 Comments

If you have any doubt in programming or join online classes then you can contact us by comment .

  1. Program of multiplication of complex numbers using complex data type-->

    x=complex(3+5j)
    print(x)
    y=complex(2+3j)
    print(y)
    multiply=x*y
    print("multiplication of complex numbers=",multiply)

    ReplyDelete
  2. Program to convert temperature from Celsius to Fahrenheit-->

    c=float(input("enter the value of c"))
    f=(9*c+160)/5
    print("temprature in fahrenheit=",f)


    ReplyDelete
  3. Program to evaluate the middle number in three-digit numbers based on order-->

    num=int(input("enter the three digit number"))
    a=num%100
    a=a//10
    print("mid number is=",a)

    ReplyDelete
  4. wap tempuratre celsius to farahenite
    temp=float(input("enter temp in celsius"))
    tf=((temp*(9/5)+32)
    print(tf)

    ReplyDelete
  5. wap tempurature farahnite to celsius
    tempf=float(input("enter temp in farhenite")
    tc=((temp-32)*(5/9))
    print(tc)

    ReplyDelete
  6. wap to perform multipication of complex number using complex data type
    comp1=complex(input("enter 1st complex number"))
    comp2=complex(input("enter 2nd complex number"))
    c=(com1*comp2)
    print(c)

    ReplyDelete
  7. Lokesh Rathore
    Multiplication of Complex Number using Complex Data Type

    Solution:-
    a=complex(2+5j)
    b=complex(4+8j)
    c=a*b
    print("The Multiplication of Complex Number is :- ", c)

    ReplyDelete
  8. Lokesh Rathore

    Print data in the single quote and double quote ?
    Solution:-
    print("'Hello Lokesh !!!!'")
    '''To Print the String in single Quote, Write the sentence in Double Quote with Single Quote.'''
    print('"Hello Lokesh !!!!"')
    '''To Print the string in Double Quote , Write the sentence in Single Quote with Double Quote.'''

    ReplyDelete
  9. deependra singh jadaunNovember 3, 2020 at 8:31 PM

    c=float(input("enter temperature in centigrade"))
    f=((9/5)*c)+(32)
    print(f)

    ReplyDelete
  10. wap to multiply complex no.
    a=2+3j
    b=3+5j
    print(a*b)

    ReplyDelete
  11. program to find mid no.
    number=int(input("enter the three digit number"))
    a=number%100
    a=a//10
    print("middle number is=",a)

    ReplyDelete
  12. program to print any data in single quote and double quote-:
    d=input("enter any data")
    print("'{}'" .format(d))
    print('"{}"'.format(d))

    ReplyDelete

Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post