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
What is peopleware?<br>need help​
Oksana_A [137]

Answer:

Peopleware is a term used to refer to one of the three core aspects of computer technology, the other two being hardware and software.

3 0
3 years ago
What does NVRAM stand for
Julli [10]
Non-Volatile Random Access Memory
7 0
3 years ago
Read 2 more answers
Which terms describes Benito Mussolini’s form of government
slega [8]
The political system that describes Benito Mussolini’s form of government would be totalitarian.Hope this answers the question:)
5 0
3 years ago
Read 2 more answers
is a programming model that focuses on an application's components and data and methods the components use. Group of answer choi
ZanzabumX [31]

Object-oriented programming is a programming model that focuses on an application's components and data and methods the components use.

<h3>What is Object-oriented programming (OOP)?</h3>

This is known to be a form of  a programming paradigm that is known to be due to the idea of "objects", that often contain data and code.

Note that, Object-oriented programming is a programming model that focuses on an application's components and data and methods the components use.

Learn more about programming model from

brainly.com/question/22654163

#SPJ1

7 0
2 years ago
What are the paragraph different formatting paragraph tools?draw its icon and state its function.
aliya0001 [1]

Theres Tab, And File


:)

7 0
3 years ago
Other questions:
  • What happens when your computer is in Hibernate mode?
    12·1 answer
  • What is a flash player?
    9·2 answers
  • Which is the default scripting language in most browsers? A. ASP B. JavaScript C. PHP D. XML
    12·1 answer
  • A cell has an unlimited number of conditions for Conditional Formatting.<br> A.true<br> B.false
    7·1 answer
  • You just bought a hard drive, you plan on using this a secondary storage, once installed, what needs to be done to the drive and
    6·1 answer
  • Write a program name Dollars that calculates and displays the conversion of an entered number of dollars into currency denominat
    11·1 answer
  • Command create database in oracle database ::((
    8·1 answer
  • Write a function named reverse_list that takes as a parameter a list and and reverses the order of the elements in that list. It
    12·1 answer
  • Help pweaseee!! Lloyd has created a validation script for a data entry form. What property should he use to test for a selected
    10·1 answer
  • Which device is used to direct the flow of data on a computer network?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!