greyash99
August 25th, 2006, 02:10 AM
im trying to make a decimal to binary converter. What I cant get it to do is get the decimal to correspond to its value in my binary list.
#! /usr/local/bin/python
import os
if os.environ['USER']:
print 'Hello, '+os.environ['USER']
decimal = ["0","1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"]
binary = ["0", "1", "10", "11", "100", "101", "110", "111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111", "10000", "10001", "10010", "10011", "10100"]
hexa = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "10", "11", "12", "13", "14"]
print "select your conversion"
print "1 decimal to binary"
print "2 decimal to hexadecimal"
print "3 binary to decimal"
print "4 binary to hexadecimal"
print "5 hexadecimal to decimal"
print "6 hexadecimal to binary"
conversion = input(">")
if conversion == 1:
number = float(raw_input("what number?")
print binary
#! /usr/local/bin/python
import os
if os.environ['USER']:
print 'Hello, '+os.environ['USER']
decimal = ["0","1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"]
binary = ["0", "1", "10", "11", "100", "101", "110", "111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111", "10000", "10001", "10010", "10011", "10100"]
hexa = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "10", "11", "12", "13", "14"]
print "select your conversion"
print "1 decimal to binary"
print "2 decimal to hexadecimal"
print "3 binary to decimal"
print "4 binary to hexadecimal"
print "5 hexadecimal to decimal"
print "6 hexadecimal to binary"
conversion = input(">")
if conversion == 1:
number = float(raw_input("what number?")
print binary