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
ArbitrLikvidat [17]
3 years ago
14

Write function d2x() that takes as input a nonnegative integer n (in the standard decimal representation) and an integer x betwe

en 2 and 9 and returns a string of digits that represents the base-x representation of n.
Computers and Technology
1 answer:
Rufina [12.5K]3 years ago
4 0

Answer:

The function in Python is as follows:

def d2x(d, x):

   if d > 1 and x>1 and x<=9:

       output = ""

       while (d > 0):

           output+= str(d % x)

           d = int(d / x)

       output = output[::-1]

       return output

   else:

       return "Number/Base is out of range"

Explanation:

This defines the function

def d2x(d, x):

This checks if base and range are within range i.e. d must be positive and x between 2 and 9 (inclusive)

   if d >= 1 and x>1 and x<=9:

This initializes the output string

       output = ""

This loop is repeated until d is 0

       while (d > 0):

This gets the remainder of d/x and saves the result in output

           output+= str(d % x)

This gets the quotient of d/x

           d = int(d / x) ----- The loop ends here

This reverses the output string

       output = output[::-1]

This returns the output string

       return output

The else statement if d or x is out of range

<em>    else:</em>

<em>        return "Number/Base is out of range"</em>

<em />

You might be interested in
What is not an example of ai
BARSIC [14]

Answer:

human

Explanation:

because it is not a machine

8 0
3 years ago
Read 2 more answers
A software development _____________ provides a framework for designing, writing, and testing software.
Ivenika [448]
I think methodology
4 0
3 years ago
How many dimples are on the titleist pro v1 golf ball?
ICE Princess25 [194]
Hey and thanks for giving me the chance to serve you
__________________________________________________________ 

There are 392 dimples on a Pro V 1,
Hope this helped.

Have a good day.
5 0
3 years ago
When two or more tables share the same number of columns, and when their corresponding columns share the same or compatible doma
ryzh [129]

Answer:

:Union compatible

Explanation:

Two parameters are said to be similar or union compatible if both the parameter have similar attribute.

In DBMS, two table are said to be union compatible if they have same attribute and same attribute domain.

It help to draw the attention toward the structure of the table that shows that all the attribute on which table has been drawn are same in both given table.

8 0
4 years ago
List 7 internal components in a computer system
MrRa [10]
Motherboard
processor
graphic card
memory
storage
power supply
sound card
6 0
3 years ago
Read 2 more answers
Other questions:
  • Which keyword helps you remember how to operate an extinguisher? A. MASH B. PASS C. PASH D. DASH
    11·2 answers
  • The home keys on the numeric keypad are?
    15·2 answers
  • One cost of starting your own business is _____.
    12·1 answer
  • Heelo how do u do python syntax lesson 11 on code academy
    12·1 answer
  • Which are examples of email client programs?<br> hand<br> are examples of email client programs.
    5·1 answer
  • Floating point numbers?
    9·1 answer
  • Which statement about technology before the invention of the printing press is true?
    8·1 answer
  • What are some of the functions in the Consolidate dialog box? Check all that apply.
    6·1 answer
  • PLEASE HELP!!!
    11·1 answer
  • Jane wants to type a math assignment involving percentages she wants to insert the percent symbol after typing a number which ke
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!