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
3 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]3 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
What is network topology? PLZZZ HURRY
Mashcka [7]

Answer:

Network topology is the arrangement of the elements (links, nodes, etc.) of a communication network. Network topology can be used to define or describe the arrangement of various types of telecommunication networks, including command and control radio networks, industrial field busses and computer networks.

7 0
2 years ago
Which job role requires you to create user guides for computer products and services?
kipiarov [429]

For plato I think technical writer is the answer.

Technical writer: As a technical writer, you’ll create user manuals and support guides for a number of computer products and services. You may also develop content to market technical products online.

4 0
2 years ago
Read 2 more answers
What are the answers to everfi
FinnZ [79.3K]
FutureSmart focuses on the important Middle School years by empowering students to become the stewards of their financial futures. This three hour web-based resource educates students on the practicalities of daily financial decisions and the payoffs of long-term planning. Since Middle School is an important period for positive habits
to take form and grow, this course is particularly meaningful.
Through a compelling narrative in which students play the Mayor of a town, local citizens are helped with real-life decisions. From weighing opportunity costs, to delaying instant gratification for long- term gain, students face important questions on their way to becoming FutureSmart. At the end of the course, students compose their own blueprint for the future. FutureSmart c
6 0
2 years ago
Write an algorithm to get the value of length and breadth of a rectangle from the user and find its area. inn qbasic
Shalnov [3]

Answer:

IN PYTHON ::

x=int(input('Enter length:'))

y=int(input('Enter width:'))

print('Area of the rectangle is', x*y,'squared units')

I hope it will be useful.

5 0
2 years ago
A penetration tester is experimenting with Network Mapper (Nmap) on a test network as a privileged user. The tester would like t
kondor19780726 [428]

The Network Mapper (Nmap) commands that would be useful on this test network are:

  1. nmap xxx.xxx.x.x -p
  2. nmap xxx.xxx.x.x -A

<h3>What is a penetration test?</h3>

A penetration test can be defined as a cybersecurity technique that simulates a cyber attack against an end user's computer system, so as to scan, identify, test and check for exploitable vulnerabilities in the following:

  • Operating system
  • Web software
  • Host device
  • Network

This ultimately implies that, a penetration test avails an tester the ability to exploit a weakness and potential security threats on a test network as a privileged user, during vulnerability assessments of the system.

<h3>The Network Mapper (Nmap) commands.</h3>

In this scenario, the Network Mapper (Nmap) commands that would be useful on this test network are:

  1. nmap xxx.xxx.x.x -p
  2. nmap xxx.xxx.x.x -A

Read more on penetration test here: brainly.com/question/25813524

6 0
2 years ago
Other questions:
  • What aspect do you need to keep in mind when you add images in a word document?
    11·2 answers
  • 1.
    13·1 answer
  • An online service provider provides its users with hosted computers, an operating system, and a database management system (DBMS
    12·1 answer
  • Advantages of e commerce
    14·1 answer
  • Explain how arrays are stored in memory? Show how arr [5] is stored in the memory. Assume each memory location is one byte long
    6·1 answer
  • private int product(int n) { if(n &lt;= 1) return 1; else return n * product(n-2); } What is the output when product(6) is calle
    6·1 answer
  • Who's hype for Halo Infinite?
    11·2 answers
  • GUYS THERE IS A HACKER IN BRAINLY PLEASE DONT PRESS ON THE WEBSITE THEY WILL HACK YOU.
    9·2 answers
  • What plugs into this?
    6·2 answers
  • Data becomes _______ when it is presented in a format that people can understand and use.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!