Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Program, using only if and elif statements [The following table lists an octave of music notes, beginning with middle C, along with their frequencies.

Python Program, using only if and elif statements

[The following table lists an octave of music notes, beginning with middle C, along with their frequencies.

Note

Frequency (Hz)

C4

261.63

D4

293.66

E4

329.63

F4

349.23

G4

392.00

A4

440.00

B4

493.88

Begin by writing a program that reads the name of a note from the user and displays the notes frequency. Your program should support all of the notes listed previously.

+

Once you have your program working correctly for the notes listed previously you should add support for all of the notes from C0 to C8. While this could be done by adding many additional cases to your if statement, such a solution is cumbersome, inelegant and unacceptable for the purposes of this exercise. Instead, you should exploit the relationship between notes in adjacent octaves. In particular, the frequency of any note in octave n is half the frequency of the corresponding note in octave n 1. By using this relationship, you should be able to add support for the additional notes without adding additional cases to your if statement.]

In the previous question you converted from note name to frequency. In this question you will write a program that reverses that process. Begin by reading a frequency from the user. If the frequency is within one Hertz of a value listed in the table in the previous question then report the name of the note. Otherwise report that the frequency does not correspond to a known note. In this exercise you only need to consider the notes listed in the table. There is no need to consider notes from other octaves.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Compare the current team to the ideal team.

Answered: 1 week ago

Question

a. Do team members trust each other?

Answered: 1 week ago

Question

How do members envision the ideal team?

Answered: 1 week ago