How to convert he boolean values into integers

Discussion in 'Python' started by krishna, Jun 25, 2009.

  1. krishna

    krishna Guest

    Hi Guys,

    I need to convert 1010100110 boolean value to some think like 2345, if
    its possible then post me your comment on this

    Advanced thanks for all

    Narayana perumal.G
     
    krishna, Jun 25, 2009
    #1
    1. Advertising

  2. krishna wrote:
    > I need to convert 1010100110 boolean value to some think like 2345, if
    > its possible then post me your comment on this


    Yes, sure. You can simply sum up the digit values and then format them as
    decimal number. You can also just look up the number:

    def decode_binary(input):
    for i in range(2**len(input)):
    if bin(i)==input:
    return str(i)

    I Hope I was able to help you with your homework! ;^)

    Uli

    --
    Sator Laser GmbH
    Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
     
    Ulrich Eckhardt, Jun 25, 2009
    #2
    1. Advertising

  3. krishna

    samwyse Guest

    >>> int('1010100110', 2)
    678

    On Jun 25, 7:06 am, krishna <> wrote:
    > Hi Guys,
    >
    > I need to convert 1010100110 boolean value to some think like 2345, if
    > its possible then post me your comment on this
    >
    > Advanced thanks for all
    >
    > Narayana perumal.G
     
    samwyse, Jun 25, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus Zeindl

    How do I convert characters into integers?

    Markus Zeindl, Dec 14, 2004, in forum: Python
    Replies:
    8
    Views:
    423
  2. Replies:
    0
    Views:
    279
  3. J Leonard
    Replies:
    4
    Views:
    12,763
    Mark Space
    Jan 19, 2008
  4. Pokkie
    Replies:
    1
    Views:
    252
    Keenan Newton
    May 6, 2005
  5. Metre Meter
    Replies:
    7
    Views:
    403
    Metre Meter
    Aug 6, 2010
Loading...

Share This Page