In PythonRestrictions There is exactly one import statement allowed in this project: import random oYou are not allowed to import anything else. oYou can only use randint () choice ( ) and seed() from the random library You are not allowed to use classes, exceptions, the with statement, and list/dictionary comprehensions. From the built-in functions, you are allowed to use: orange), len ( ), sorted(), int ( ), sum(), list (), float(), str ( ) From list methods, you are allowed to use: o append(), insert ( ), copy(), remove), pop ( ), index) From the dictionary methods, you are allowed to us: o get), values ( ), keys(), items), update ( ) For the file/string methods, you are allowed to use: o open(), strip ( ), split(), join() o read(), readline ( ) , readlines ( ), write ( ), writelines( You may not make more than one pass of a file when reading it. Do not circumvent this rule by reading in the file as one entity (one string, a list, etc.), and then performing multiple passes on that. Questions on Piazza like “Can I use [thing not listed above] ?” will not be answered by an instructor generate_durations ( base_tempo ) Description: Generates a dictionary of note durations dictated by the base tempo. This is how long each note should be played based on tempo of the song. Assume that one measure of the song is equivalent to four heats A quarter note would then last for one beat, a half note for two beats, a whole note for four beats, an eighth nte for half of a beat, and sixteenth note for a quarter of a beat. Parameters: base_tempo (positive integer), expressed in beats per minute. Return value: a dictionary of keys (strings) and values (floats) that maps note types to seconds Example: Whole’: 4.0, ‘Half’: 2.0, ‘Quarter’: 1.0, ‘Eighth’: 0.5, ‘Sixteenth’: 0.25 generate_durations ( 60) Show transcribed image text Restrictions There is exactly one import statement allowed in this project: import random oYou are not allowed to import anything else. oYou can only use randint () choice ( ) and seed() from the random library You are not allowed to use classes, exceptions, the with statement, and list/dictionary comprehensions. From the built-in functions, you are allowed to use: orange), len ( ), sorted(), int ( ), sum(), list (), float(), str ( ) From list methods, you are allowed to use: o append(), insert ( ), copy(), remove), pop ( ), index) From the dictionary methods, you are allowed to us: o get), values ( ), keys(), items), update ( ) For the file/string methods, you are allowed to use: o open(), strip ( ), split(), join() o read(), readline ( ) , readlines ( ), write ( ), writelines( You may not make more than one pass of a file when reading it. Do not circumvent this rule by reading in the file as one entity (one string, a list, etc.), and then performing multiple passes on that. Questions on Piazza like “Can I use [thing not listed above] ?” will not be answered by an instructor
generate_durations ( base_tempo ) Description: Generates a dictionary of note durations dictated by the base tempo. This is how long each note should be played based on tempo of the song. Assume that one measure of the song is equivalent to four heats A quarter note would then last for one beat, a half note for two beats, a whole note for four beats, an eighth nte for half of a beat, and sixteenth note for a quarter of a beat. Parameters: base_tempo (positive integer), expressed in beats per minute. Return value: a dictionary of keys (strings) and values (floats) that maps note types to seconds Example: Whole’: 4.0, ‘Half’: 2.0, ‘Quarter’: 1.0, ‘Eighth’: 0.5, ‘Sixteenth’: 0.25 generate_durations ( 60)
Expert Answer
Answer to Restrictions There is exactly one import statement allowed in this project: import random oYou are not allowed to import…