Saturday, April 9, 2016

Decimal To Hexadecimal in Python


A simple program that I wrote using Python programming language that will ask the user to give decimal number and then our program will convert the given number into its hexadecimal equivalent.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

def my_program():
   print()
   print("DECIMAL TO HEXADECIMAL CONVERTER")
   print()
   decimal = int(input("Enter a Number: "))
   print()
   print('The number {0} in Decimal is equivalent to '.format(decimal))
   print(hex(decimal), " in Hexadecimal.");
   print("\n");
   repeat = input('Do you want to continue ? (Y/N) : ')

   if repeat.upper() == "N":
       print("\n")
       print("END OF PROGRAM")
       quit
   if repeat.upper() == "Y":
       my_program()

if __name__ == '__main__':
       my_program()


No comments:

Post a Comment