1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vivado [14]
3 years ago
12

Write a program that asks the user to enter a positive integer that represents a number in the decimal system and then displays

the binary representation of the number. Your solution must include at least the following function: decimalToBinary(number): a recursive function that takes a positive integer number (in decimal) as its parameter and returns a string with it's binary representation. g
Computers and Technology
1 answer:
Maru [420]3 years ago
3 0

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

<em>    if num == 0: </em>

<em>        return 0 </em>

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)))

You might be interested in
Unicode is a world standard to represent _________________
horsena [70]

Answer:

characters.

Explanation:

We need to represent characters in binary format so that they can be stored in computer memory. Earlier, ASCII (American Standard Code for Information Interchange) representation was commonly used for english characters. But ASCII was found to be insufficient for representing multilingual and special characters.Unicode character representation was developed to overcome this limitation.

8 0
3 years ago
PLEASE HELP!!!!!
Allushta [10]

Answer:

Insert

Explanation:

Insert

7 0
4 years ago
Read 2 more answers
What is an example of a way a farm could apply new technology to improve sustainability?
Bess [88]

An example of a way a farm could apply new technology to improve sustainability is via the use artificial intelligence to predict and adjust the farm's water usage.

<h3>How is artificial intelligence used in farming?</h3>

The use of AI systems is one that can help to make better the total harvest quality and accuracy which is known to be precision agriculture.

Note that An example of a way a farm could apply new technology to improve sustainability is via the use artificial intelligence to predict and adjust the farm's water usage.

Learn more about sustainability from

brainly.com/question/26195041

#SPJ2

4 0
2 years ago
One way to align and organize your table of contents is by using _______, which are dotted lines that precede your typed informa
bekas [8.4K]
They are dot leaders......
8 0
4 years ago
First, open two separate terminal connections to the same machine, so that you can easily run something in one window and the ot
dusya [7]
Dnt listen to da file shi
7 0
3 years ago
Other questions:
  • HELP! I am trying to get my google account back for school and business, can someone help?
    9·1 answer
  • How can a wiki contribute to an academic paper?
    9·2 answers
  • Jenny is the project manager and her company. She needs to break her current project into parts that her employees can work on.
    10·1 answer
  • What are 2 ways to access the vendor credit screen in quickbooks online?
    13·1 answer
  • Help me guys pleassssssssse​
    12·1 answer
  • For questions 3-6, consider the following two-dimensional array:
    11·2 answers
  • // This class calculates a waitperson's tip as 15% of the bill public class DebugThree1 { public static void main(String args[])
    10·1 answer
  • 25 POINTS!! NEED HELP ASAP!! Which of the following can be a problem for people with certain kinds of epilepsy?
    15·1 answer
  • You can open a movie maker project file any time in a media player. (1 point) true false
    6·1 answer
  • A packet switch has 5 users, each offering packets at a rate of 10 packets per second. The average length of the packets is 1,02
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!