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 binary 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 convert_binary(values):
if values > 1:
convert_binary(values//2)
print(values % 2,end = '')
def my_program():
print()
print("DECIMAL TO BINARY CONVERTER")
print()
decimal = int(input("Enter a Number: "))
print()
print('The number {0} in Decimal is equivalent to '.format(decimal))
convert_binary(decimal);
print(" in binary.");
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