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
Oksi-84 [34.3K]
3 years ago
5

Write a recursive method named digitSum that accepts an integer as a parameter and returns the sum of its digits. For example, c

alling digitSum(1729) should return 1 7 2 9, which is 19. If the number is negative, return the negation of the value. For example, calling digitSum(-1729) should return -19.
Computers and Technology
1 answer:
harkovskaia [24]3 years ago
4 0

Answer:

The function in Python is as follows:

def digitSum( n ):

if n == 0:

 return 0

if n>0:

    return (n % 10 + digitSum(int(n / 10)))

else:

    return -1 * (abs(n) % 10 + digitSum(int(abs(n) / 10)))

Explanation:

This defines the method

def digitSum( n ):

This returns 0 if the number is 0

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

<em>  return 0 </em>

If the number is greater than 0, this recursively sum up the digits

<em> if n>0: </em>

<em>     return (n % 10 + digitSum(int(n / 10))) </em>

If the number is lesser than 0, this recursively sum up the absolute value of the digits (i.e. the positive equivalent). The result is then negated

<em> else: </em>

<em>     return -1 * (abs(n) % 10 + digitSum(int(abs(n) / 10)))</em>

You might be interested in
If a printer is not Wi-Fi capable, how can it be set up to provide the most reliable wireless printing
SCORPION-xisa [38]

Answer:

Well you can use bluetooth since it doesn’t require wifi and it would still work if your printing a file from your computer or your flash drive.

5 0
3 years ago
Read 2 more answers
In approximately 50 words, describe the most common manufacturing systems and list some of the career opportunities in manufactu
Nezavi [6.7K]

Answer: SEE EXPLANATION

Explanation:

The manufacturing system refers to a collection of of procedures steps and processes involved in the creation of a desired product. Manufacturing systems include common which is the oldest and usually performed manually. The intermittent system which allows the production of more than one product from a single production line. The continuous system which favors massive production of a single product and the flexible system which offers enhanced technological mechanism to aid efficient production.

Careers in manufacturing include Quality Assurance, Machinist, steam and boiler technicians Food processing technologist among others.

6 0
4 years ago
Plz Help!! How should I answer the second question?
Harman [31]

Answer:

Just keep doing what you were doing explain what you would be doing in the future or where you see yourself in like 5 years and put details and things that make since to you!

4 0
3 years ago
Direction. See
storchak [24]

Answer:

1.A

2.A

3.B

4.A

5.D

6.A

..............

8 0
3 years ago
Dani wants to create a web page to document her travel adventures. Which coding language should she use? HTML Java Python Text
Anna [14]

Answer:

HTML, CSS, JavaScript, python, SQL

Explanation:

To create a web page for her travel adventures Dani has to use HTML and CSS to design the page's layout. A beautiful simple design such as one which shows photos of her on her travel destinations, and a paragraph for her to write a little story on her travels would do.

Dani needs JavaScript to animate the photos she's going to post on the page. Dani also should use python to build the backend of her page so she can write codes to save and access her documented adventures from the database. She should use a database language like SQL to save all of her adventures so she can view them at a later time for the memories.

7 0
3 years ago
Other questions:
  • Regarding an intrusion detection system (IDS), stateful matching looks for specific sequences appearing across several packets i
    9·1 answer
  • Which command let’s you increase or decrease the on-screen magnification of your document
    11·1 answer
  • Write a program in pascal to solve a quadratic equation
    12·1 answer
  • A personal phone directory contains room for first names and phone numbers for 30 people. Assign names and phone numbers for the
    15·1 answer
  • Which of the following is NOT true about variables?
    13·1 answer
  • The various online technology tools that enable people to communicate easily via the Internet to share information and resources
    5·1 answer
  • To make a complicated task easier, use a _____.
    12·1 answer
  • One or more access points positioned on a ceiling, wall, or other strategic spot in a public place to provide maximum wireless c
    9·1 answer
  • A period in which unemployment is low, business produces many goods and services, and wages are good is called ______.
    8·1 answer
  • Please help me answering this question
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!