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
Mariulka [41]
2 years ago
15

a.Write a Python function sum_1k(M) that returns the sum푠푠= ∑1푘푘푀푀푘푘=1b.Compute s for M = 3 by hand and write

another function test_sum_1k() that calls sum_1k(3) and checks that the answer is correct. When you call the sum_1k(3) function, you will see some messages according to if the test is successful or not.
Computers and Technology
1 answer:
stealth61 [152]2 years ago
8 0

Answer:

def sum_1k(M):

   s = 0

   for k in range(1, M+1):

       s = s + 1.0/k

   return s

def test_sum_1k():

   expected_value = 1.0+1.0/2+1.0/3

   computed_value = sum_1k(3)

   if expected_value == computed_value:

       print("Test is successful")

   else:

       print("Test is NOT successful")

test_sum_1k()

Explanation:

It seems the hidden part is a summation (sigma) notation that goes from 1 to M with 1/k.

- Inside the <em>sum_1k(M)</em>, iterate from 1 to M and calculate-return the sum of the expression.

- Inside the <em>test_sum_1k(),</em> calculate the <em>expected_value,</em> refers to the value that is calculated by hand and <em>computed_value,</em> refers to the value that is the result of the <em>sum_1k(3). </em>Then, compare the values and print the appropriate message

- Call the <em>test_sum_1k()</em> to see the result

You might be interested in
When typing an outline, you can move a point from a lower level to a higher level by changing the list level from the outline me
Arte-miy333 [17]
A shift+Tab
I hope it’s work
6 0
2 years ago
1st answer will get brainliest!
valentina_108 [34]

The answer is program!

5 0
2 years ago
Read 2 more answers
How can you tell if your car is overheating?
Nitella [24]
A) your temp gauge is moving into red
4 0
3 years ago
Read 2 more answers
You are building a network and need to connect five computers in an office. They will be on the same network segment and you sho
lilavasa [31]

Answer:

a lan party

Explanation:

because it's your personal party

4 0
3 years ago
Factor completely: 4y^2 - y - 3
notsponge [240]

Answer:

(4y + 3)(y - 1)

Explanation:

4 {y}^{2}  - y  - 3

4 {y}^{2}  - 4y + 3y - 3

4y(y  - 1) + 3(y - 1)

(4y + 3)(y - 1)

7 0
2 years ago
Read 2 more answers
Other questions:
  • Does anybody know how to use these showers?
    11·2 answers
  • Which line in the following program will cause a compiler error? #include using namespace std; int main() { int number =5; if (n
    10·1 answer
  • Define the missing method. licenseNum is created as: (100000 * customID) licenseYear, where customID is a method parameter. Samp
    14·2 answers
  • Write a function named change() that has an integer parameter and six integers reference parameters named hundreds, fifties, twe
    7·1 answer
  • Should the use of hacktivists by a country against enemy organizations be considered an act of war? Why or why not? How about th
    8·1 answer
  • An important communication principle states ""prepare before you communicate."" How should this preparation manifest itself in t
    10·1 answer
  • Write the correct statements for the above logic and syntax errors in program below.
    12·1 answer
  • Create a script that will determine how many of each currency type are needed to make change for a given amount of dollar and ce
    8·1 answer
  • what is the term for software that is exclusively controlled by a company, and cannot be used or modified without permission?
    6·1 answer
  • Say true or false
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!