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
Write a program to calculate the
marishachu [46]

Answer:

blep blep blep belp belp belp belp belp belp BELPPPPPPPPPP

5 0
3 years ago
What type of object can offer the most effective way to display data and calculations in a presentation?
poizon [28]

This is definitely an opinion, but an excel you can do A and D and just about the same as B also

<u>So i'd say C </u>

8 0
3 years ago
REEEEEEE I STILL NEED MORE AESTHETIC USERNAMES TO GO OFF OF PWEASE HELP IMA HAVE A PANIC ATTACK!!!... next post ima do a vote :&
aev [14]

StrawberryTeaa (could be any fruit: blueberry, peach, etc)

potatoxchip

pastelsquid

SquishyPeach

GummiBear

ElegantFlaws (could add an e and remove the s: EleganteFlaw)

hunnie_b (or honee, honnie, hunni, etc)

agonyisheree

It's cool if you don't like these. I had trouble when I changed my user too. But you'll find your perfect username eventually. :)

7 0
3 years ago
_____ returns the smallest integer greater than or equal to 7.3
Artist 52 [7]

Answer:

Explanation:

Required

Which returns smallest integer greater than or equal to 7.3

i.e.

x \le 7.3

When executed, the result of each instruction is:

ceil(7.3) = 8 -- This returns the smallest integer greater than 7.3

floor(7.3) = 7 --- This returns the smallest integer less than 7.3

<em></em>larger(7.3)<em> --- there is no such thing as larger() in python</em>

round(7.3) = 7 --- This rounds 7.3 to the nearest integer

From the above result,

8 is the smallest integer greater than or equal to 7.3

i.e.

8 \ge 7.3

Hence:

ceil(7.3) is correct

5 0
3 years ago
An investigator responsible for tracking e-mail communication would begin by locating what
Ainat [17]
Email headers contains information about email
6 0
3 years ago
Other questions:
  • On a DTP project, Morgan is preparing digital files to be sent to a printer. Which word describes the activity that Morgan is pe
    5·2 answers
  • what properties are associated with all Microsoft Office files and include author, title, and subject
    5·1 answer
  • Easy question how the internet has impacted y’all life
    13·1 answer
  • The CPU is referred to as the ______ of the computer.
    14·2 answers
  • How to use translate on a website?
    15·1 answer
  • Create a Produceclass that hasan instance variable of type Stringfor the name, appropriate constructors, appropriate accessor an
    13·1 answer
  • How can you assess a website for currency?
    14·2 answers
  • Write a java program to find the perimeter of a triangle with sides measuring 10cm, 14cm and 15 cm.
    8·1 answer
  • On a piano, a key has a frequency, say f0. Each higher key (black or white) has a frequency of f0 * rn, where n is the distance
    15·1 answer
  • PA theme is a major message that a writer convoys through a text. you have explored many themes in the hobbit one theme in the n
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!