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]
3 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]3 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
6. A genre of video game in which a player chooses a character and builds, upskills and modifies that character is referred to a
Mama L [17]
C is the answer as action games have big impact on children’s lives
3 0
3 years ago
Read 2 more answers
Rate my dog out of ten give explanation why
Karolina [17]

Answer:

10/10

Explanation:

i love dogs. he's a super cute dog and i love him without even knowing him

7 0
3 years ago
What is science worksheet answers name the three features that make science different from other human endeavors?
Tresset [83]

The three features that make science different from other human endeavors is that

  • Scientists handles issues that regards only with the natural world.
  • Scientists do collect and organize information in a careful, orderly way.
  • Scientists  do propose some explanations that can be tested by the act of evaluating evidence.

<h3>What is the definition of science?</h3>

The definition of the term  science is known to be a term that connote a system that is an organized method that is often used with evidence to be able to learn about the natural world.

Therefore, The three features that make science different from other human endeavors is that

  • Scientists handles issues that regards only with the natural world.
  • Scientists do collect and organize information in a careful, orderly way.
  • Scientists  do propose some explanations that can be tested by the act of evaluating evidence.

Learn more about science from

brainly.com/question/17216882

#SPJ1

6 0
2 years ago
What natural boundary separated british territory from louisiana?
Marat540 [252]
<span>Quebec and British; French and Indian War</span>
4 0
3 years ago
Fitbit is an example of....
strojnjashka [21]

Answer:

a monitor of ur heartbeat sleep breathing

Explanation:

3 0
4 years ago
Read 2 more answers
Other questions:
  • The email application used by Jim’s office is sending emails with viruses attached to them to user’s computers. What step should
    13·2 answers
  • Percy is a lighting technician in a film production. For a shot, the chief lighting technician instructs Percy to get the kind o
    15·1 answer
  • Suppose that you have been running an unknown sorting algorithm. Out of curiosity, you once stopped the algorithm when it was pa
    8·1 answer
  • To activate Spelling and Grammar check using the ribbon, navigate first to the _____ tab
    14·2 answers
  • The two parts of a packet are the certificate and the While storms could be a cause, power _________ are more likely to be cause
    11·1 answer
  • When changing printer settings, which of the following statements is true?
    13·1 answer
  • Which of the following is the path to the Zoom button?
    8·1 answer
  • What is the full form of 'Rom<br>​
    7·2 answers
  • Type the correct answer in the box. Spell all words correctly. Which language should you use to add functionality to web pages?
    5·1 answer
  • What is the decimal number 86 when written as a
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!