Sunday, January 30, 2022

Decimal To Binary Number in Python

 Machine Problem

Write a program to ask the user to give a decimal number  and then the program will convert the given decimal number
into binary number equivalent and display the results on the screen.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg

Thank you very much for your support.





Program Listing


# Machine Problem
#
# Write a program to ask the user to give a decimal number
# and then the program will convert the given decimal number
# into binary number equivalent and display the results on
# the screen.


print()
print("\tDecimal To Binary Number in Python")
print()

decimal = int(input("\tGive a decimal number : "))
binary = 0
a = 0
temp = decimal


while(temp > 0):
binary = ((temp%2)*(10**a)) + binary
temp = int(temp/2)
a += 1

print()
print("\tThe Binary of {x} is {y}.".format(x=decimal,y=binary))
print()
print("\tEnd of Program")
print()


No comments:

Post a Comment