Computers and Technology

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 the sums of the squares and sum of the cubes using the explicit formula below.

1**2 + 2**2 + 3**2 + + n**2 = n(n+1)(2n+1)/6
1**3 + 2**3 + 3**3 + + n**3 = n**2(n+1)**2/4
write functions to add these formulas to your program and print out their results as well as that of the explicit summations. the user dialog will look something like this:

warning: the equations above a math equation and the syntax may not work for python as written.

the sum of squares is 55
the sum of cubes is 225

the explicit sum of squares is 55
the explicit sum of cubes is 225

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 17:30, kameronstebbins
Which tab should you open to find the option for adding a header?
Answers: 1
image
Computers and Technology, 22.06.2019 18:00, alexj29227405
Write a method named addall that could be placed inside the hashintset class. this method accepts another hashintset as a parameter and adds all elements from that set into the current set, if they are not already present. for example, if a set s1 contains [1, 2, 3] and another set s2 contains [1, 7, 3, 9], the call of s1.addall(s2); would change s1 to store [1, 2, 3, 7, 9] in some order. you are allowed to call methods on your set and/or the other set. do not modify the set passed in. this method should run in o(n) time where n is the number of elements in the parameter set passed in.
Answers: 2
image
Computers and Technology, 22.06.2019 18:30, Akkenson17871
The "instance" relationship shows that something is an object of a
Answers: 1
image
Computers and Technology, 23.06.2019 05:00, sharkboy578
Acompany is inviting design for its new corporate logo from its users. this is an example of ? a. crowdfunding b. crowdvoting c. crowdsourced design d. crowdtracking
Answers: 3
Do you know the correct answer?
Write a function addupsquaresandcubes that adds up the squares and adds up the cubes of integers fro...

Questions in other subjects:

Konu
Mathematics, 28.02.2021 23:40
Konu
Mathematics, 28.02.2021 23:40