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
ozzi
4 years ago
8

Write a function addUpSquaresAndCubes that adds up the squares and adds up the cubes of integers from 1 to N, where N is entered

by the user. This function should return two values - the sum of the squares and the sum of the cubes. Use just one loop that generates the integers and accumulates the sum of squares and the sum of cubes. Then, write two separate functions sumOfSquares and sumOfCubes to calculate and return the sums of the squares and sum of the cubes using the explicit formula below.
Computers and Technology
1 answer:
avanturin [10]4 years ago
7 0

Answer:

All functions were written in python

addUpSquaresAndCubes Function

def addUpSquaresAndCubes(N):

    squares = 0

    cubes = 0

    for i in range(1, N+1):

         squares = squares + i**2

         cubes = cubes + i**3

    return(squares, cubes)

sumOfSquares Function

def sumOfSquares(N):

    squares = 0

    for i in range(1, N+1):

         squares = squares + i**2

    return squares

sumOfCubes Function

def sumOfCubes(N):

    cubes = 0

    for i in range(1, N+1):

         cubes = cubes + i**3

    return cubes

Explanation:

Explaining the addUpSquaresAndCubes Function

This line defines the function

def addUpSquaresAndCubes(N):

The next two lines initializes squares and cubes to 0

    squares = 0

    cubes = 0

The following iteration adds up the squares and cubes from 1 to user input

    for i in range(1, N+1):

         squares = squares + i**2

         cubes = cubes + i**3

This line returns the calculated squares and cubes

    return(squares, cubes)

<em>The functions sumOfSquares and sumOfCubes are extract of the addUpSquaresAndCubes.</em>

<em>Hence, the same explanation (above) applies to both functions</em>

You might be interested in
Web résumés allow you to include extra graphics and images that you would not include in a traditional résumé. please select the
Reil [10]

A web resume is much better than a traditional resume because it can carry so much data about the person and it includes images also.

<h3>What is a web resume?</h3>

A web resume is defined as a resume that is read by a computer program that summarizes the information of each employee.

Web resume contains the data such as their education, skills, job experience, languages, and so on.

Thus, the photo of the project or internship that has been done in past can be shown on the web resume by uploading the certificate on the computer system along with the resume.

For example, the company takes the information of the person on their server before the interview.

More about the web resume link is given below.

brainly.com/question/862477

7 0
2 years ago
Convert each number into scientific notation.
Fudgin [204]

Answer:

4 * 10^9

2.7 * 10^-8

6.776 * 10^7

9.05*10^4

5.409*10^5

9.04 * 10^-3

3.2 * 10^-2

5.12 * 10^8

Explanation:

1. 4,000,000,000

4 * 1,000,000,000 = 4 * (10*10*10*10*10*10*10*10*10) = 4 * 10^9

2. 0.000000027

27 * 10^-9 = 2.7 * 10^-8

0.000000027 = 2.7 * 10^-8

3. 67,760,000 = 6776 * 10000

6776 * 10000 = 6776 * 10^4

6776 * 10^4 = 6.776 * 10^3 * 10^4 = 6.776 * 10^7

4. 90,500

905 * 100 = (9.05 * 100) * 100

(9.05*100) * 100 = 9.05 * 10^2 * 10^2 = 9.05*10^4

5. 540,900

5409 * 100 = (5.409 * 1000) * 100

(5.409*1000)*100 = 5.409*10^3 * 10^2

5.409*10^3 * 10^2 = 5.409*10^5

6.) 0.00904

0.00904 = 904 * 10^-5

904 * 10^-5 = 9.04 * 10^-3

7. 0.032

32 * 10^-3 = 3.2 * 10^-2

8. 512,000,000

512 * 1000000

512 * 10^6 = 5.12 * 10^2 * 10^6 = 5.12 * 10^8

5 0
3 years ago
Derek, a project manager, needs to create a plan for a software development project. Which approach or document will help him de
Lady_Fox [76]
For this one I would say C.) Work Breakdown Structure
6 0
3 years ago
As you begin to develop a software application, what is one of the most helpful tools to ensure a quality product?
Nutka1998 [239]
Input processing output chart
3 0
4 years ago
The best way to safeguard your document is to save it
givi [52]
The answer is C every few minutes
8 0
3 years ago
Other questions:
  • Where can you access email accounts on your windows 7 computer in order to modify current accounts or create new ones?
    5·1 answer
  • A ____ in Excel is like a notebook.
    8·1 answer
  • WILL GIVE  BRAINLIEST!! WILL REPORT TOO....
    13·1 answer
  • All web traffic is based on the ____________________ protocol.
    14·1 answer
  • You can use this effect to break a color into a percentage of its full strength.
    13·1 answer
  • When configuring services, what linux directory typically contains server configuration files?
    8·1 answer
  • A Security Policy is: a. How we implement security b. Corporate direction on behavior c. A statement of consequence for failure
    5·1 answer
  • to minimize wrist injury switch frequently among touch gestures the keyboard and the mouse true or false
    15·1 answer
  • True or False: Mapping annotations are exclusive - an annotated method will only be accessible to requests sent to a matching UR
    14·1 answer
  • What are some real-life situations where multi-dimensional arrays might be useful?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!