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
Describe a problem you’ve solved or a problem you’d like to solve. It can be an intellectual challenge, a research query, an eth
iogann1982 [59]

Answer:

Explanation:

I run an online e-commerce store and lately its been very difficult keeping track of customer detail, incoming orders, keyword generation etc. One solution that I thought about would be an application that controls all of that for me. In order to accomplish this I would first need to design and create a GUI that contains all of the necessary buttons and displays for the information. Then I would need to code a webscraper using Python to grab all of the data from e-commerce store as soon as it becomes available, organize it, and display it within the GUI.

6 0
3 years ago
What city was the capital of Portuguese colonies in Asia
olga2289 [7]

Answer:

Goa was the capital of Portuguese colonies in Asia.

Explanation:

7 0
3 years ago
HELP THIS IS SO DIFFICULT
HACTEHA [7]
It would be 11111, and decimal 31
7 0
3 years ago
Read 2 more answers
What effect do you think this will have on the program when you run it?
Mandarinka [93]
It depends on what program you are running.
8 0
3 years ago
Which of the following is not a common operating system? A) Apple B) Linux C) Unix D) Windows Vista​
sleet_krkn [62]

Answer:

A) Apple

Explanation:

An operating system is a system software pre-installed on a computing device to manage or control software application, computer hardware and user processes.

This ultimately implies that, an operating system acts as an interface or intermediary between the computer end user and the hardware portion of the computer system (computer hardware) in the processing and execution of instructions.

Some examples of an operating system on computers are QNX, Linux, OpenVMS, MacOS, Microsoft windows, IBM, Solaris, VM etc.

Apple is not a common operating system.

However, MacOS is an operating system that is designed and developed by an American multinational technology company called Apple Inc.

5 0
3 years ago
Other questions:
  • Which soft skill involves the ability to work harmoniously with your colleagues and improve productivity?
    14·1 answer
  • What is a palindrome?
    13·1 answer
  • Parallel tangent and coincident are examples of what
    13·1 answer
  • _______ Originally , the art of maganing engines; in its modern and extended sense
    7·1 answer
  • You are interested in buying a laptop computer. Your list of considerations include the computer's speed in processing data, its
    15·1 answer
  • Text can be inserted into a presentation by
    7·1 answer
  • CAN SOMEONE PLEASE HELP ME WITH THIS PLEASE ?!!!!!!!!
    14·1 answer
  • With which type of satellite is there a propagation delay?
    5·1 answer
  • What are the three computer components that hold a dangerous amounts of electricity? Even when it’s unplugged.
    15·1 answer
  • Explain employment opportunities in the networking field 
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!