Respuesta :
Answer:
In Python:
def decimalToBinary(num):
if num == 0:
return 0
else:
return(num%2 + 10*decimalToBinary(int(num//2)))
decimal_number = int(input("Decimal Number: "))
print("Decimal: "+str(decimalToBinary(decimal_number)))
Explanation:
This defines the function
def decimalToBinary(num):
If num is 0, this returns 0
if num == 0:
return 0
If otherwise
else:
num is divided by 2, the remainder is saved and the result is recursively passed to the function; this is done until the binary representation is gotten
return(num%2 + 10*decimalToBinary(int(num//2)))
The main begins here.
This prompts the user for decimal number
decimal_number = int(input("Decimal Number: "))
This calls the function and prints the binary representation
print("Decimal: "+str(decimalToBinary(decimal_number)))
In this exercise we have to use the knowledge in computational language in python to describe a code that best suits, so we have:
The code can be found in the attached image.
To make it simpler we can write this code as:
def decimalToBinary(num):
if num == 0:
return 0
else:
return(num%2 + 10*decimalToBinary(int(num//2)))
decimal_number = int(input("Decimal Number: "))
print("Decimal: "+str(decimalToBinary(decimal_number)))
See more about python at brainly.com/question/19705654
![Ver imagen lhmarianateixeira](https://us-static.z-dn.net/files/d2b/54520409b4893b3d558d938493949f43.png)