[Tutor] (no subject)

Ghadir Ghasemi ghasemmg01 at leedslearning.net
Mon Feb 4 18:52:18 CET 2013

hi guys, this is the first bit of my program converting from binary to decimal without use of built in functions.

binnum = input("Please enter a binary number:  ")
decnum = 0
rank = 1

for i in reversed(binnum):
    decnum += rank * int(i)
    rank *= 2

When I first tested the program, It printed the answer in a weird way. you can see the print screen of first tirst in the attachment. I wanted to know how I could adjust the program so that
it only prints the real answer. e.g If user enters 11111111, then program should only print 255.
thank you.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: firstprogramttest.PNG
Type: image/x-png
Size: 18199 bytes
Desc: firstprogramttest.PNG
URL: <http://mail.python.org/pipermail/tutor/attachments/20130204/d0f0796e/attachment-0001.bin>

More information about the Tutor mailing list