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
Consider two communication technologies that use the same bandwidth, but Technology B has twice the SNR of technology A. If tech
MrRissso [65]

Answer:

55kbps

Explanation:

7 0
3 years ago
If you want to share information with individuals who are internal to your organization, which type of network would you want to
11Alexandr11 [23.1K]

it is globe because I want a successful the all people

8 0
3 years ago
A computer can sort x objects in t seconds, as modeled by the function below:
zavuch27 [327]
T = 9 = 0.005x^2 + 0.002x

0.005x^2 + 0.002x - 9 = 0

To solve this quadratic equation divide by 0.005

x^2 + 0.4x - 1800 = 0

x = {-b +/- √[b^2 -4ac] } / 2a = {-0.4 +/-√[0.16 + 7200]} / 2 = { - 0.4 +/- 84.85}/2 =

Use only the positive result: x =  42.2 = 42

Answer: 42
6 0
3 years ago
A vehicle fails an HC emission test at idle and 2,500 rpm, and the engine has an acceleration stumble. The heated oxygen sensor
Natalija [7]

I would say a defective O2 sensor

6 0
4 years ago
What are the names of different types of tablets<br>​
jekas [21]

Answer:

iPad

IPad mini

IPad Pro

IPad air

Samsung Galaxy tab

Galaxy Tab e

galaxy tab pro

Galaxy tab 2

Explanation:

Also maybe could you look at my 3 biology questions i really need help

5 0
3 years ago
Other questions:
  • Which is the last step in conducting a url research
    11·1 answer
  • What view and zoom setting do you need for true WYSIWYG display? Why?
    14·1 answer
  • Daniela’s company has made the decision to allow employees to work from home as the company has outgrown their physical space. K
    13·1 answer
  • Match the number in the picture to the correct Excel interface part. Each number is only used one time.
    11·1 answer
  • Write a function to output an array of ints on a single line. Funtion Should take an array and an array length and return a void
    9·1 answer
  • After clicking the Start button on your computer screen desktop, what option would you then select to examine system components
    15·1 answer
  • A photographer uses which of these tools to form an argument?
    14·2 answers
  • "Rights and duties are two sides of the same coin." Explain with examples​
    5·1 answer
  • The Self-Quiz gives you an opportunity to self-assess your knowledge of what you have learned so far.
    13·1 answer
  • You are developing a Website that is going to be viewed extensively on smartphones and tablets. Which of the following should yo
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!