🎁BACK-TO-SCHOOL DEAL. Subscribe Now to get 40% OFF at only 8.49 USD/month, only valid until Sep 30th, 2024

Question

Question
Problem 2 - Minor Key Here is a list of musical notes, written with flats (rather than sharps): CDb, D, Eb, E, F, Gb,G,Ab. ABb. B, C in the next octave) Observe that not all notes have flats, Le.Cflat is actually B which is not a black key on the piano for instance The harmonic minor scale is composed of the following sequence of steps: Step] [ Step) | Step) [Step] [13 Step] [1% Step] [ Step] For instance, the Charmonic minor scale is C, D, E, F, G, A.B.C. Each musical "half step" is a single step through the list, the name half-step predates computers so you have to forgive musicians a little. The Eb harmonic minor scale is Eb F Gb Ab Bb BDE The G harmonic minor scale is GABb CDE5 GbG Define a list: MUSICAL NOTES - ['c', D\u2660', 'D', 'E\0266d', TE", "Gu2663', 'G', A\u266d', 'A', '\u2660". Note that \u266d' is the unicode for the flat symbol Allow the user to enter starting notes like: "E* or "B flat" or "flat" You will have to calculate the starting note from this, or if it's not a note, for instance if they enter "R" Then display the harmonic minor scale starting at that note, or an error message indicating that it is not a note. When the user enters "quit then stop asking for notes and exit the program, My suggestion is that you break this problem down into parts: 1) Translate the input into the musical notation by creating a Thelper function' which takes as a parameter the user's input and outputs the proper note, meaning it will replace 'flat' with b and remove the space, so that it matches the description in the list of strings. 2) Compute the starting index in the list of musical notes or determine that the starting index doesn't exist because the note isn't a real note. I use another helper function for this purpose. 3) Calculate the scale itself in a slightly bigger function but then return it as a list. 4) Outside of your function, implement a main loop where you will join the answer together and output it. This is generally how programmers think about problems. We attempt to break each problem into subproblems which we can write small functions to solve. Then we put those functions together and get our final results. Sample Output linux5[109] python3 minor_key py Enter a starting note (D. E flat): G GAB CD EGG Enter a starting note (C, D flat): A ABCDETA A Enter a starting note (c, Dalat): A flat A B B D E EGA Enter a starting note (C, D flat): flat There is no starting note R. Enter a starting note (C, D flat): quit linux5[110]\ python3 minor_key.PY Enter a starting note (D, E flat): C CDEFGABC Enter a starting note (C, D flat): D DEFGAB DD Enter a starting note (C, D flat): E flat EFG A B BDE Enter a starting note c, flat): G GAB CD EGG Enter a starting note (C, D flat): flat DEEA ACD Enter at ting note (C, D flat): quit

Asked By CrimsonShadow33 at

Answered By Expert

Stephen

Expert · 5.4k answers · 5k people helped


musical_notes = (
    "C",
    "D\u266d",
    "D",
    "E\u266d",
    "E",
    "F",
    "G\u266d",
    "G",
    "A\u266d",
    "A",
    "B\u266d",
    "B",
)

valid_inputs = [x.replace("\u266d", " flat").lower() for x in musical_notes]


def harmonic_minor_scale_generator(start_index):
    scale_indices = [0, 2, 3, 5, 7, 8, 11, 12]
    scale_list = []
    for x in scale_indices:
        scale_list.append(musical_notes[(x + start_index) % 12])
    return scale_list


playing = True
while playing:
    in_data = input("Enter a starting note (C,D flat):").strip()
    if in_data.lower() == "quit":
        playing = False
    elif in_data.lower() in valid_inputs:
        start_index = valid_inputs.index(in_data.lower())
        print(*harmonic_minor_scale_generator(start_index))
    else:
        print("There is no starting note", in_data.replace(" flat", "\u266d"))

The following python code can be used to solve the problem mentioned above.

🧑‍🏫 More Questions

and 2 Fill in the blanks: All tissues consist of two main components: , which consists of a gelatinous substance called numerous different and 3 An epithelial tissue that has one layer of rectangular cells would be classified as a stratified squamous epithelium. b. simple cuboidal epithelium. c stratified columnar epithelium d simple columnar epithelium 4 How do pseudostratified ciliated columnar epithelium and transitional epithelium differ from other types of epithelia? 5 True False: Mark the following statements concerning connective tissue proper and cartilage as true () or false 0). If the statement is false, correct it to make it a true statement Adipocytes contain a large lipid droplet in their cytoplasm. The primary element in dense regular collagenous connective tissue is ground substance. Bundles of collagen fibers are arranged parallel to one another in dense inregular colagenous connective tissue. Loose connective tissue contains all three protein fiber types Fibrocartilage has a smooth, glassy appearance due to a large amount of ground substance and few visible protein fibers 6 Which of the following best characterizes the extracellular matrix (ECM of bone tissue? a Bonetissue ECM consists of only calcium hydroxyapatite crystals b. Bone tissue ECM Consists of calcium hydroxyapatite crystals and collagen fibers c Bone tissue ECM consists of only colagen fibers. d. Bone tissue ECM consists of collagen, elastic, and reticular fibers. 7 Circle all that apply. Which of the following characteristics apply to skeletal muscle tissue a Striated b. Nonstrated C Multinucleate d Uninucleate e Contains intercalated discs. Voluntary 9 Involuntary h. Autorhythmic 128 - Exploring Anatomy & Physiology in the Laboratory