Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Summary of Datatypes in Python 3

Vinay Rawal answered on April 1, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • summary in python
  • What are the basic data types in Python, and how do I use them?

  • Summary of Datatypes in Python 3

    0

    Datatype

    Description

    Is Immutable?

    Example Int We can use to represent the whole/integral numbers Immutable >>> a=10 >>> type(a)

    Float

    We can use to represent the decimal/floating point numbers

    Immutable

    >>> b=10.5

    >>> type(b)

    Complex We can use to represent the complex numbers Immutable >>> c=10+5j >>> type(c) >>> c.real 10.0 >>> c.imag 5.0

    Bool

    We can use to represent the logical values (Only allowed values are True and False)

    Immutable

    >>> flag=True

    >>> flag=False

    >>> type(flag)

    Str To represent sequence of Characters Immutable >>> s='durga' >>> type(s) >>> s="durga" >>> s='''Durga Software Solutions... Ameerpet''' >>> type(s)

    bytes

    To represent a sequence of byte values from 0-255

    Immutable

    >>> list=[1,2,3,4]

    >>> b=bytes(list)

    >>> type(b)

    bytearray To represent a sequence of byte values from 0-255 Mutable >>> list=[10,20,30] >>> ba=bytearray(list) >>> type(ba)

    range

    To represent a range of values

    Immutable

    >>> r=range(10)

    >>> r1=range(0,10)

    >>> r2=range(0,10,2)

    31 https://www.youtube.com/durgasoftware

    list To represent an ordered collection of objects Mutable >>> l=[10,11,12,13,14,15] >>> type(l)

    tuple

    To represent an ordered collections of objects

    Immutable

    >>> t=(1,2,3,4,5)

    >>> type(t)

    set To represent an unordered collection of unique objects Mutable >>> s={1,2,3,4,5,6} >>> type(s)

    frozenset

    To represent an unordered collection of unique objects

    Immutable

    >>> s={11,2,3,'Durga',100,'Ramu'}

    >>> fs=frozenset(s)

    >>> type(fs)

    dict To represent a group of key value pairs Mutable >>> d = {101:'durga', 102:'ramu', 103:'hari'} >>> type(d)

    14) None Data Type:  None means nothing or No value associated.  If the value is not available, then to handle such type of cases None introduced.  It is something like null value in Java.

    Eg: def m1(): a=10

    print(m1()) None 

    Popularity 1/10 Helpfulness 1/10 Language python
    Source: Grepper
    Tags: python summary
    Link to this answer
    Share Copy Link
    Contributed on Apr 01 2023
    Vinay Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.