Advertisement
SkilledScorpion

Mark 3 | Number Converter

Sep 12th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. converter = "Yes"
  2. while converter == "Yes":
  3.    
  4.     fromSystem = input("\nChoose b (Binary), d (Decimal) or h (Hex) for the Numerical System that you would like to convert from: ")    
  5.     if fromSystem == 'b':
  6.         toSystem = input("Choose b (Binary), d (Decimal) or h (Hex) for the Numerical System that you would like to convert to: ")
  7.         if toSystem == 'd':
  8.             binaryNumber = input("Enter binary number: ")
  9.             endResult = int(binaryNumber, 2)
  10.             print("\n", binaryNumber, "as a decimal value is", endResult, "\n")
  11. #       elif fromSystem == 'h' or 'H':
  12. #           binaryNumber = input("Enter binary number: ")
  13. #           print (int(binaryNumber, 2))
  14.         else:
  15.             print("Those letters or combination of letters will not work. Pleaser try again with different letters \n")
  16.  
  17.     elif fromSystem == 'd':
  18.         toSystem = input("Choose b (Binary), d (Decimal) or h (Hex) for the Numerical System that you would like to convert to: ")
  19.         if toSystem == 'b':
  20.             decimalNumber = int(input("Enter decimal number: "))
  21.             endResult = bin(decimalNumber)[2:]
  22.             print("\n", decimalNumber, "as a decimal value is", endResult, "\n")
  23. #       elif toSystem == 'h':
  24. #           decimalNumber = input("Enter binary number: ")
  25. #           print (int(binaryNumber, 2))        
  26.         else:
  27.             print("Those letters or combination of letters will not work. Pleaser try again with different letters \n")
  28.  
  29. #elif fromSystem == 'h':
  30. #   toSystem = input("Choose b (Binary), d (Decimal) or h (Hex) for the Numerical System that you would like to convert to: ")
  31. #   if toSystem == 'b':
  32. #        hexNumber = input("Enter hexadecimal number: ")
  33. #        print (int(binaryNumber, 2))
  34. #
  35. #   elif toSystem == 'd':
  36. #        hexNumber = input("Enter hexadecimal number: ")
  37. #        print
  38. #
  39. #   else:
  40. #        print("Those letters or combination of letters will not work. Pleaser try again with different letters")  
  41.     else:
  42.         print("That letter will not work. Pleaser try again with different letters \n")
  43.        
  44.     continueConverter = input("Continue, yes or no? ")
  45.     if continueConverter == "Yes" or continueConverter == "yes" or continueConverter == "Y" or continueConverter == "y":
  46.         continue
  47.     elif continueConverter == "No" or "no" or "N" or "n":
  48.         converter == "No"
  49.     else:
  50.         continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement