Write a recursive method named digitSum that accepts an integer as a parameter and returns the sum of its digits. For example, calling 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.

Answers

Answer 1

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

if n == 0:

 return 0

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

if n>0:

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

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

else:

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


Related Questions

what functions can you perform with project management software?

Answers

Answer:

Planning and scheduling. ...

Collaboration. ...

Documentation. ...

Reporting. ...

Resource management. ...

Managing the project budget.

Explanation:

Which of the following are examples of nontoxic materials used in computer equipment?
gold, silver, copper
arsenic, copper, gold
dioxin, silver, gold
copper, silver, lead

Answers

Answer: Gold, Silver, Copper

Explanation:

Gold is very useful in computers as it can be used for connectors, connecting wires and even memory chips. It is a nonreactive metal and so is not toxic unless it is consumed (and in large quantities).

Silver is another nontoxic metal used in computers to make circuit boards, cellphones and even keyboard components. Finally there is the very important copper which is a useful electronic component for more than just computers. This non-toxic metal has contributed significantly to the development of many things electrical including, as already mentioned, computers.

public class Square extends Shape{
/**Like with Shape, we will be making a static instance variable
* to keep track of how many squares we have made. It is very
* similar to the one in shape, and it's uses are similar as well.
* It too is initialized to zero.
*
* We may also need additional instance variables, which you should
* declare as needed. They will not need to be static nor initialized
* here though.
**/
/**You may need additional instance variables. Declare them here.
**/
/**The constructor for Square is a little more involved than the
* Shape constructor, as it takes a single double parameter representing
* the side length. It should also call the super constructor, as
* calling it increments the number of shapes made, which we should
* do (as a Square extends Shape). We also need to increment the
* instance variable representing the number of squares made, and handle
* our parameter appropriately.
**/
public Square(double sideLength){
}
/**Like with our other shapes, this is a simple getter method for our
* static instance variable.
**/ public static int getNumSquaresMade(){
return -1;
}
/**As always, we must override getSize() for our Square. A Square's size
* is simply it's side length squared.
**/
}
public class Shape{
private static int numShapesMade = 0;
public Shape(){
numShapesMade++;
}
public static int getNumShapesMade(){
return numShapesMade;
}
public double getSize(){
return 0;
}
}

Answers

Answer:

I would say A

Explanation:

Enjoy :)

Populations are effected by the birth and death rate, as well as the number of people who move in and out each year. The birth rate is the percentage increase of the population due to births and the death rate is the percentage decrease of the population due to deaths. Write a program that displays the size of a population for any number of years. The program should ask for the following data:
• The starting size of a population
• The annual birth rate
• The annual death rate
• The number of years to display
Write a function that calculates the size of the population for a year. The formula is
N = P + BP − DP
where N is the new population size, P is the previous population size, B is the birth rate, and D is the death rate.
Input Validation: Do not accept numbers less than 2 for the starting size. Do not accept negative numbers for birth rate or death rate. Do not accept numbers less than 1 for the number of years.
#include
using namespace std;
double calcOfPopulation(double, double, double);
double inputValidate(double, int);
int main()
{
double P, // population size
B, // birth rate %
D, // death rate %
num_years;
cout << "Starting size of population: ";
P = inputValidate(P, 2);
cout << "Annual birth rate: %";
B = inputValidate(B, 0);
cout << "Annual death rate: %";
D = inputValidate(D, 0);
cout << "Number of years to display: ";
num_years = inputValidate(num_years, 1);
cout << "Population size for "
<< num_years << " years "
<< " = "
<< (calcOfPopulation(P, B, D) * num_years)
<< endl;
return 0;
} // END int main()
double inputValidate(double number, int limit)
{
while(!(cin >> number) || number < limit)
{
cout << "Error. Number must not be "
<< " 0 or greater:";
cin.clear();
cin.ignore(numeric_limits::max(), '\n');
}
return number;
}
double calcOfPopulation(double P, double B, double D)
{
B *= .01; // 3.33% = .0333
D *= .01; // 4.44% = .0444
return P + (B * P) - (D * P);

Answers

Answer:

See attachment for program source file

Explanation:

The source code in the question is not incorrect; just that, it was poorly formatted.

So, what I did it that:

I edited the source code to be in the right formats.numeric_limits needs the <limits> header file to work properly. The <limits> header file was not included in the original source file; so, I added #include<limits> at the beginning of the source fileI corrected the wrongly declared function prototypes.

See attachment for the modified program source file

Write a class named Employee that has private data members for an employee's name, ID_number, salary, and email_address. It should have an init method that takes four values and uses them to initialize the data members. It should have get methods named get_name, get_ID_number, get_salary, and get_email_address. Write a separate function (not part of the Employee class) named make_employee_dict that takes as parameters a list of names, a list of ID numbers, a list of salaries and a list of email addresses (which are all the same length). The function should take the first value of each list and use them to create an Employee object. It should do the same with the second value of each list, etc. to the end of the lists. As it creates these objects, it should add them to a dictionary, where the key is the ID number and the value for that key is the whole Employee object. The function should return the resulting dictionary. For example, it could be used l

Answers

Solution :

class Employee:

   #Define the

   #constructor.

   def __[tex]$\text{init}$[/tex]__([tex]$\text{self, nam}e$[/tex],  ID_number, [tex]$\text{salary}$[/tex], email):

       #Set the values of

       #the data members of the class.

       [tex]$\text{self.nam}e$[/tex] = name

       [tex]$\text{self.ID}$[/tex]_number = ID_number

       [tex]$\text{self.salary}$[/tex] = salary

       self.email_address = email

#Define the function

#make_employee_dict().

def make_employee_dict(list_names, list_ID, list_salary, list_email):

   #Define the dictionary

   #to store the results.

   employee_dict = {}

   #Store the length

   #of the list.

   list_len = len(list_ID)

   #Run the loop to

   #traverse the list.

   for i in range(list_len):

       #Access the lists to

       #get the required details.

       name = list_names[i]

       id_num = list_ID[i]

       salary = list_salary[i]

       email = list_email[i]

       #Define the employee

       #object and store

       #it in the dictionary.

       employee_dict[id_num] = Employee(name, id_num, salary, email)

   #Return the

   #resultant dictionary.

   return employee_dict

When parameters are passed between the calling code and the called function, formal and actual parameters are matched by: a.

Answers

Answer:

their relative positions in the parameter and argument lists.

Explanation:

In Computer programming, a variable can be defined as a placeholder or container for holding a piece of information that can be modified or edited.

Basically, variable stores information which is passed from the location of the method call directly to the method that is called by the program.

For example, they can serve as a model for a function; when used as an input, such as for passing a value to a function and when used as an output, such as for retrieving a value from the same function. Therefore, when you create variables in a function, you can can set the values for their parameters.

A parameter can be defined as a value that must be passed into a function, subroutine or procedure when it is called.

Generally, when parameters are passed between a calling code and the called function, formal and actual parameters are usually matched by their relative positions in the parameter and argument lists.

A formal parameter is simply an identifier declared in a method so as to represent the value that is being passed by a caller into the method.

An actual parameter refers to the actual value that is being passed by a caller into the method i.e the variables or values that are passed while a function is being called.

how do you fix The lag on your zsnes emulator I’m playing it on My laptop

Answers

Answer:

Use a laptop that is not a potato.

Explanation:

ZSNES has super low system requirements, so if it's running poorly you are probably running it on a potato. You might also try a different emulator such as BSNES, if you think that the problem is not the underpowered computer.

Abstract: Design, implement, explain, test, and debug a simple, but complete command- line interpreter named cli.
Detail: Design, implement, document, test and run a simple shell, known here as a command-line interpreter (cli). This tool is invoked via the cli command plus possible arguments. Commands are OS commands to be executed. Multiple commands are separated from one another by commas, and each may in turn require further arguments. Cli 'knows' a list of commands a-priori; they are predefined. When invoked, cli checks, whether the first argument is an included command. If so, cli confirms this via a brief message. If not, a contrary message is emitted, stating this is not one the predefined commands. After the message, cli executes all commands in the order listed. After executing the last command, cli prints the current working directory, i.e. it acts as if the pwd command had been issued. Sample runs are shown further below.
Multiple commands of cli must be separated from one another by commas. Possible parameters of any one command are separated from the command itself (and from possible further parameters) by white space. White space consists of blanks, tabs, or a combination, but at least 1 blank space. Here some sample runs with single and multiple commands; outputs are not shown here: .
/cli pwd looks like Unix command pwd; is your sw .
/cli rm -f temp, mv temp ../temp1 ditto: input to your running homework 5
./cli ls -la another "single unix command"
./cli rm a.out, gcc sys.c, cp a.out cli
Cli starts out identifying itself, also naming you the author, and the release date. Then cli prints the list of all predefine commands. Finally, cli executes all commands input after the cli invocation. For your own debug effort, test your solution with numerous correct and also wrong inputs, including commas omitted, multiple commas, leading commas, illegals commands, other symbols instead of commas etc. No need to show or hand-in your test and debug work.
The output of the cli command "cli pwd" or "./cli pwd" should be as shown below, assuming your current working directory is ./classes Sac State/csc139. Here is the output of a sample run with a single command line argument:
herbertmayer$ ./cli pwd
hgm cli 4/12/2020
Legal commands: cd exec exit gcc Is man more mv rm pwd sh touch which $path
2 strings passed to argv[]
next string is 'pwd'
new string is 'pwd
1st cind 'pwd' is one of predefined
/Users/herbertmayer/herb/academia/classes Sac State/csc139
Here the output of another sample run, also with a single cli command:
herbertmayer$ ./cli ls
hgm cli 4/12/2020
Legal commands: cd exec exit gcc ls man more mv rm pwd sh touch which Spath
2 strings passed to argv[]
next string is 'ls'
new string is 'ls!
1st cmd 'is' is one of predefined. admin cli.c sac state yyy
backup 1 24 2020 docs sac state hw
backup 3 9 2020 grades sac state xxx
cli 1 notes
/Users/herbertmayer/herb/academia/classes Sac State/csc139
Interpretation of commands that cli handles can proceed through system(), executed from inside your C/C++ program cli.
List of all commands supported by your cli:
char * cmds [ ] = {
"cd",
"exec",
"exit",
"gcc",
"ls",
"man",
"more",
"mv",
"Im
"pwd"
"sh",
"touch",
"which",
"Spath"
What you turn in:
1. The source program of your homework solution; well commented, preferably one single source file.
2. Four progressively more complex executions of your correctly working cli program, showing all user inputs and corresponding output responses.

Answers

Answer:

that is very long question ask a profesional

Explanation:

To iterate through (access all the entries of) a two-dimensional arrays you
need for loops. (Enter the number of for loops needed).

Answers

Answer: You would need two loops to iterate through both dimensions

Explanation:

matrix = [[1,2,3,4,5],

              [6,7,8,9,10],

              [11,12,13,14,15]]

for rows in matrix:

    for numbers in rows:

         print(numbers)

The first loop cycles through all the immediate subjects in it, which are the three lists. The second loop calls the for loop variable and iterates through each individual subject because they are lists. So the first loop iterates through the 1st dimension (the lists) and the seconds loop iterates through the 2nd dimension (the numbers in the lists).

To iterate through (access all the entries of) a two-dimensional arrays you need two for loops.

What is an array?

A collection of identically typed items, such as characters, integers, and floating-point numbers, are kept together in an array, a form of data structure.

A key or index that can be used to retrieve or change the value kept in that location identifies each element in the array.

Depending on how many indices or keys are used to identify the elements, arrays can be one-dimensional, two-dimensional, or multi-dimensional.

Two nested for loops are often required to iterate over a two-dimensional array: one to loop through the rows, and the other to loop through the columns.

As a result, two for loops would be required to access every entry in a two-dimensional array.

Thus, the answer is two for loops are required.

For more details regarding an array, visit:

https://brainly.com/question/19570024

#SPJ6

explain the errors in each error in spreadsheet and how to correct each​

Answers

Answer:

###### error. Problem: The column is not wide enough to display all the characters in a cell. ...

# Div/0! error. ...

#Name? error. ...

#Value! error. ...

#REF! error. ...

#NUM! error. ...

#NULL error.

Explanation:

// Exercise 4.16: Mystery.java
2 public class Mystery
3 {
4 public static void main(String[] args)
5 {
6 int x = 1;
7 int total = 0;
8
9 while (x <= 10)
10 {
11 int y = x * x;
12 System.out.println(y);
13 total += y;
14 ++x;
15 }
16
17 System.out.printf("Total is %d%n", total);
18 }
19 } // end class Mystery

Answers

Answer:

385

Explanation:

There was no question so I simply run the program for you and included the output.

The program seems to calculate: [tex]\sum\limits_{x=1}^{10} x^2[/tex]

2.
When parking on hills or an unlevel surface, make sure your
is engaged when you leave the vehicle.
A. turn signal
B. accelerator
C. brake pedal
D. parking brake

Answers

Answer:

D. parking brake

Explanation:

Plzz help will mark brainliest

Answers

Answer:

11. 3 dimensions

12. ( i believe its number 3)

13. 2 option

14. Natural Light

15. Development

Explanation:

state two ways of moving an icon from one location to another​

Answers

Answer:

To arrange icons by name, type, date, or size, right-click a blank area on the desktop, and then click Arrange Icons.

Click the command that indicates how you want to arrange the icons (by Name, by Type, and so on).

If you want the icons to be automatically arranged, click Auto Arrange.

If you want to arrange the icons on your own, click Auto Arrange to remove the check mark.

Explanation:

In this lab, you use what you have learned about searching an array to find an exact match to complete a partially prewritten C program. The program uses an array that contains valid names for 10 cities in Michigan. You ask the user to enter a city name; your program then searches the array for that city name. If it is not found, the program should print a message that informs the user the city name is not found in the list of valid cities in Michigan. The file provided for this lab includes the input statements and the necessary variable declarations. You need to use a loop to examine all the items in the array and test for a match. You also need to set a flag if there is a match and then test the flag variable to determine if you should print the the Not a city in Michigan. message. Comments in the code tell you where to write your statements. You can use the previous Mail Order program as a guide. Instructions Ensure the provided code file named MichiganCities.cpp is open. Study the prewritten code to make sure you understand it. Write a loop statement that examines the names of cities stored in the array. Write code that tests for a match. Write code that, when appropriate, prints the message Not a city in Michigan.. Execute the program by clicking the Run button at the bottom of the screen. Use the following as input: Chicago Brooklyn Watervliet Acme

Answers

Answer:

Complete the program as follows:

for(int i = 0; i<10; i++){

     if(inCity == citiesInMichigan[i]){

         foundIt = true;

         break;       }    }

   if(foundIt){         cout<<"It is a city";     }

   else{         cout<<"Not a city";     }

Explanation:

Required

Complete the pre-written code in C++ (as indicated by the file name)

The pre-written code; though missing in this question, can be found online.

The explanation of the added lines of code is as follows:

This iterates through the array

for(int i = 0; i<10; i++){

This checks if the city exists in the array

     if(inCity == citiesInMichigan[i]){

If yes, foundIt is updated to true

         foundIt = true;

And the loop is exited

         break;       }    } -- The loop ends here

If foundIt is true, print it is a city

   if(foundIt){         cout<<"It is a city";     }

Print not a city, if otherwise

   else{         cout<<"Not a city";     }

// MichiganCities.cpp - This program prints a message for invalid cities in Michigan.// Input: Interactive// Output: Error message or nothing#include <iostream>#include <string>using namespace std;int main(){ // Declare variables string inCity; // name of city to look up in array const int NUM_CITIES = 10; // Initialized array of cities string citiesInMichigan[] = {"Acme", "Albion", "Detroit", "Watervliet", "Coloma", "Saginaw", "Richland", "Glenn", "Midland", "Brooklyn"}; bool foundIt = false; // Flag variable int x; // Loop control variable // Get user input cout << "Enter name of city: "; cin >> inCity; // Write your loop here for (x = 0; x < NUM_CITIES; x++) { // Write your test statement here to see if there is // a match. Set the flag to true if city is found. if (inCity == citiesInMichigan[x]) { foundIt = true; cout << "City found." << endl; break; } else { foundIt = false; } } // Test to see if city was not found to determine if // "Not a city in Michigan" message should be printed. if (!foundIt) { cout << "Not a city in Michigan." << endl; } return 0; } // End of main()

it is a group of two or more computer system connect to each other​

Answers

network is a group of two or more computer system connected together

state 4 basic operation performed by a computer​

Answers

Answer:

The processes are input, output, storing,processing, and controlling.

input, processing, output, and storage.

Expectation on Information Technology Fundamental​

Answers

You can expect to develop an understanding of information systems, programming languages, information management and artificial intelligence, leaving your studies with the ability to apply your knowledge to solve problems.

What is a document?

a information about a computer file, distinct from the information it contains
a set of information gathered together
a two- to four-letter string set to the right of the dot in a filename; this designates the type of information in the file
a computer file representing a specific text item

Answers

Answer:

A document is a written, drawn, presented, or memorialized representation of thought, often the manifestation of non-fictional, as well as fictional, content. The word originates from the Latin Documentum, which denotes a "teaching" or "lesson": the verb doceō denotes "to teach" In general, a document (noun) is a record or the capturing of some event or thing so that the information will not be lost.  A document is a form of information. A document can be put into an electronic form and stored in a computer as one or more files. Often a single document becomes a single file.

What allows you to navigate up down left and right in a spreadsheet?

Answers

Answer:

scrollbar?

Explanation:

____________

list eight applications software​

Answers

Answer:

Eight applications software are:

Word processing softwareSpreadsheet software Graphics software Database software Web browser softwareAnimation softwareInternet browser softwares like: fire fox, chrome etcPresentation software

Code a Python program that uses a graphical user interface (GUI) to address a real-world problem. Within reason, you may choose to address any real-world problem that you would like; however, please only choose a real-world problem that is both safe and legal.

Answers

Answer:

Explanation:

The following is a simple GUI Python program that solves for the different variables in a Pythagorean theorem equation, which is a real-world problem that many students have to face on a daily basis. The output can be seen in the attached picture below. Due to technical difficulties, I have added the code as a txt file attachment.

1. A bank customer invested $24 in a bank with 5 percent simple interest per year, write a program the construct a table showing how much money the bank customer would have at the end of each 20- year period starting in 2021 to 2041.

2. A programmer starts with salary of $65,000 and expect to receive $1500 raise each year. Write a program to compute and print the programmer's salary for each of the first 10 years and total amount of money the programmer would receive over the 10- year period.

Answers

Answer:

1.lettuce is 2021 to 2,000 4136 verse 2. that is 10 years to tell if your 10 years 20 years old point month

Please answer it’s timed

Answers

Product safety cuz it talking about safety

Answer:

product safety

Explanation:

brainly:)^

Line 9 and 10
To calculate your taxable income, subtract the sum of lines 8
and 9 from line 7, and then enter that number here.

Answers

Answer:

22,332

Explanation:

The taxable income :

Line 8 = Standard deduction or itemized deduction

Line 9 = Qualified business income deduction

Line 7 = Adjusted gross income

Taxable income = Adjusted gross income - (Qualified business income deduction + standard deduction)

Taxable income = 34732 - (12400 + 0)

Taxable income = 34732 - 12400

Taxable income = 22,332

How wireless communication might affect the development and implementations of internet of things?​

Answers

If people send a link don’t try them report them!

Which of the following is primarily operated by a touchscreen?
Mobile device
Notebook
Desktop
Network

Answers

Answer: The correct answer is Mobile device

Explanation:

A Mobile device is any portable equipment that can be easily connected to an internet. Example of mobile devices include; smart phones, palmtop, smart watch and other computer gadgets. The use of touchscreen for input or output on mobile devices can not be overemphasized. Mobile devices are handy and can be used for making work easy. As such, in order to effectively use mobile devices, touchscreen can be primarily used.

pleaseeeeeeee tellllllllllllllllllllll​

Answers

Answer:

true is the correct answer

InfoTrac is an aggregated database?

True

False

Answers

Answer: true

Explanation:

What is the first step you should take when you want to open a savings account? A. Present your photo ID to the bank representative. B. Go to the bank and fill out an application. C. Make your initial deposit. D. Review the different savings account options that your blunk offers.​

Answers

Answer: B

Explanation:

The first step you should take when you want to open a savings account is the photo id
Other Questions
Hi! Does anyone know the answer to this question? Im bad at geometry and Im struggling to get the answer. Please help! Which terms best describe the Tang Dynasty?A. Prosperous and ArtisticB. Poor and WarlikeC. Humble and PeacefulD. Weak and Closed-Minded Jenny needs 1/2 of a stick of butter for a recipe. She cuts the half stick of butter into four equal pieces what portion of the whole stick of butter is each of the pieces I need to show my work plz 1. Who died first, Jesus or Julius Caesar? 2. Which Roman era lasted the longest: the Roman monarchy, the Roman republic, the Western Roman Empire or the Byzantine Empire?3. Did Jesus live during the Roman Republic or the Roman Empire?4. what led to the end of the Roman monarchy? 5. what led to the end of the Western Roman Empire? 6. how long did it take for Christianity to become an acceptable religion?7. Was Julius Caesar a Christian? How do you know? Bricktan Inc. makes three products, basic, classic, and deluxe. The maximum Bricktan can sell is 75,000 units of basic, 420,000 units of classic, and 120,000 units of deluxe. Bricktan has limited production capacity of 90,000 hours. It can produce 10 units of basic, 8 units of classic, and 4 units of deluxe per hour. Contribution margin per unit is $15 for the basic, $25 for the classic, and $55 for the deluxe. What is the total contribution margin if Bricktan chooses the most profitable sales mix Read, think and explain Why is a wire used to connect the electrodes in an electrochemical cell?O A. To provide the metal that is the oxidizing agentB. To prevent the flow of protons from electrodesC. So ions can flow from one electrode to anotherD. So electrons can flow from one electrode to another A local pizza shop has a membership program for frequent buyers. The membership costs $5 per month and members get a discounted price of $2 per slice of pizza. Aisha purchased a membership to this pizza shop. How much would Aisha have to pay the pizza shop if she bought 8 slices of pizza this month? What would be the monthly cost for x slices of pizza? DETERMINE WHICH OF THE ANGLE MEASURES BELOW CORRECTLYSATISFY THE MISSING VALUE, X, IN EACH DIAGRAM. when you serve in table tennis, where must the ball contact after you hit it with a paddle Pliss you can help me plisss Spanish please keep simple An angle turns through 1/360 of a circle. what is the measure, in degrees, of the angle. I really need help with this please. Please Help! Computer Sci What form of text anxiety are you relieving when you do physical activity?Select one:a.Cognitiveb.Emotionalc.Behaviorald.Physiological Suggest strategies to succeed in outsourcing its HR services Solve the following system of equation using any method. 3x+3y=122x+4y=16 X = and Y= Each day, Robert eats 40% of the pistachios leftin his jar at that time. At the end of the secondday, 27 pistachios remain. How many pistachioswere in the jar at the start of the first day? Which equation has a graph that is a parabola with a vertex at (-2, 0)?O y=-22O y = (x + 2)2O y = (x - 2)2Oy=x-2 Give two land features that can form because of deflation.