answer.
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
Sunny_sXe
2 months 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:
8_murik_8 [964]2 months ago
8 0
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() It appears that the hidden portion involves summing (sigma) from 1 to M with the term 1/k. Accordingly, within sum_1k(M), one should iterate from 1 to M to compute and return the sum of the expression. The test_sum_1k() function calculates the expected_value, an accurate hand-calculated value, while computed_value denotes the result of sum_1k(3). The values are then compared and an appropriate message is printed. Finally, invoke test_sum_1k() to observe the result.
You might be interested in
Charlie has a large book collection. He was keeping track of it in a spreadsheet, but it has grown big enough that he wants to c
Harlamova29_29 [1022]

Answer:

Review the explanation

Explanation:

Response 1) Keeping all data in a single row presents challenges; if one record in the sheet is deleted, all related records may also vanish unexpectedly. For instance, should the entry for author "James Taylor" be removed, all the books associated with him would get eliminated as well.

Response 2) In the first normal form (1NF), each row is supposed to have just one tuple, but in the case of the author "James Taylor," the title field contains two books, necessitating separation into distinct rows.

Response 3) The table shown in the image does not exhibit deletion anomalies; for the author "May Norton," if you erase this record, it will result only in the deletion of her sole book.

Thus, it’s essential to transition this table into the second normal form (2NF).

Create distinct tables for Authors and Books

Authors(Author Name, Author Country)

Books(Author Name, Book Title, Publisher, Publisher Location, Year, Price)

This cannot undergo further normalization.

3 0
3 months ago
OCR Land is a theme park aimed at children and adults. Entrance tickets are sold online. An adult ticket to OCR Land costs £19.9
Rzqust [1037]

Answer:

count = 0

while count!= 8:

height = float(input("Enter the height of the rider: "))

if height >= 140:

print("You may ride")

count += 1

else:

if height >= 120:

answer = input("Is the rider accompanied by an adult (yes/no): ")

if answer == "yes":

print("You may ride")

count += 1

else:

print("You are not permitted to ride")

else:

print("You are not permitted to ride")

Explanation:

Begin with a count of zero, which will track the number of riders allowed. Use a while loop that continues until the count reaches 8. During each iteration, request the user's height. If the height is 140 cm or taller, display "You may ride" and increment the count. If the height is 120 cm or more, check if the rider is with an adult. If not, show the message "You are not permitted to ride"; otherwise, allow the ride and increase the count. If the height is below 120 cm, deny the ride.

5 0
3 months ago
Olivia needs to get permission to use a graph of data gathered by a trade association she plans to include the graph in a report
Natasha_Volkova [1026]

She can locate the copyright notice on the webpage that features the graph.

Explanation: ~Apex~

3 0
3 months ago
Read 2 more answers
Other questions:
  • Imagine you were using some of our pixelation tools to create an image and you posted it online for your friends to see - but, a
    11·1 answer
  • Modern operating systems decouple a process address space from the machine’s physical memory. List two advantages of this design
    15·1 answer
  • U.S. industries like steel, computers, and energy need to be protected from foreign competition to ensure which of the following
    6·2 answers
  • An array subscript can be an expression, but only as long as the expression evaluates to what type?
    7·1 answer
  • In a survey of 7200 T.V. viewers, 40% said they watch network news programs. Find the margin of error for this survey if we want
    6·1 answer
  • Danielle, a help desk technician, receives a call from a client. In a panic, he explains that he was using the Internet to resea
    9·1 answer
  • Define a public static method named f2s that takes a single String argument, the name of a file. The method returns a (concievab
    13·1 answer
  • A binary search can be performed only on ____.
    6·1 answer
  • Using the Sakila database, create a query that displays the film title, description, as well the actor first and last name for a
    12·1 answer
  • what is the largest possible number of internal nodes in a redblack tree with black height k? what is the smallest possiblenumbe
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!