2014-04-26, 04:48 PM
Good news is decimal to binary and binary to decimal seem to work fine. The only one that seems to have a problem is decimal to hexadecimal.
If you make the changes where I added comments it should compile.
I would also highly recommending downloading a good python IDE - I currently use PyCharm and it works pretty well.
Code:
def decToHex():
#Get number from user
number=int(input("enter a postive number ")#Missing a parenthesis
if(number is<= 0) #What's that is doing there? Also, need a colon
0)#What's this?
print("enter a postive number")
if(number=0) #Should not be an assignment, also a colon
print("the hexadecimal value of 0 equals 0")
else #Colon needed here
hstr=" "
q=number
while(q>0):
if(q%16<10):
hstr=str(q%16)+hstr
elif(q%16==10):
hstr="A"+hstr
elif(q%16==11):
hstr="B"+hstr
elif(q%16==12):
hstr="C"+hstr
elif(q%16==13):
hstr="D"+hstr
elif(q%16==14):
hstr="E"+hstr
elif(q%16==15):
else: #This else probably shouldn't be here
hstr="F"+hstr
q=q//16
print(number, "converted to hexadecimal is " , hstr)If you make the changes where I added comments it should compile.
I would also highly recommending downloading a good python IDE - I currently use PyCharm and it works pretty well.

