Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- converter = "Yes"
- while converter == "Yes":
- fromSystem = input("\nChoose b (Binary), d (Decimal) or h (Hex) for the Numerical System that you would like to convert from: ")
- if fromSystem == 'b':
- toSystem = input("Choose b (Binary), d (Decimal) or h (Hex) for the Numerical System that you would like to convert to: ")
- if toSystem == 'd':
- binaryNumber = input("Enter binary number: ")
- endResult = int(binaryNumber, 2)
- print("\n", binaryNumber, "as a decimal value is", endResult, "\n")
- # elif fromSystem == 'h' or 'H':
- # binaryNumber = input("Enter binary number: ")
- # print (int(binaryNumber, 2))
- else:
- print("Those letters or combination of letters will not work. Pleaser try again with different letters \n")
- elif fromSystem == 'd':
- toSystem = input("Choose b (Binary), d (Decimal) or h (Hex) for the Numerical System that you would like to convert to: ")
- if toSystem == 'b':
- decimalNumber = int(input("Enter decimal number: "))
- endResult = bin(decimalNumber)[2:]
- print("\n", decimalNumber, "as a decimal value is", endResult, "\n")
- # elif toSystem == 'h':
- # decimalNumber = input("Enter binary number: ")
- # print (int(binaryNumber, 2))
- else:
- print("Those letters or combination of letters will not work. Pleaser try again with different letters \n")
- #elif fromSystem == 'h':
- # toSystem = input("Choose b (Binary), d (Decimal) or h (Hex) for the Numerical System that you would like to convert to: ")
- # if toSystem == 'b':
- # hexNumber = input("Enter hexadecimal number: ")
- # print (int(binaryNumber, 2))
- #
- # elif toSystem == 'd':
- # hexNumber = input("Enter hexadecimal number: ")
- # print
- #
- # else:
- # print("Those letters or combination of letters will not work. Pleaser try again with different letters")
- else:
- print("That letter will not work. Pleaser try again with different letters \n")
- continueConverter = input("Continue, yes or no? ")
- if continueConverter == "Yes" or continueConverter == "yes" or continueConverter == "Y" or continueConverter == "y":
- continue
- elif continueConverter == "No" or "no" or "N" or "n":
- converter == "No"
- else:
- continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement