(Solved) : Restrictions Exactly One Import Statement Allowed Project Import Random O Allowed Import A Q42704591 . . .

In Python
Restrictions • There is exactly one import statement allowed in this project: import random O You are not allowed to import a
song_as_dict(filename) Description: Transforms a song from a file into a dictionary. The information it stores is the numberRestrictions • There is exactly one import statement allowed in this project: import random O You are not allowed to import anything else. O You 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: o range(), 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. song_as_dict(filename) Description: Transforms a song from a file into a dictionary. The information it stores is the number of notes (separated by octaves) and note types that appear in the given song. Parameters: filename (string) the name of the song file to use Return value: A dictionary with four keys: “tempo”, “tuning”, “notes” and “types” The “tempo” key is just the value of the tempo of the song, and the “tuning” key is the value of the tuning frequency of the song. The “notes” key is a dictionary that maps each individual note to another. dictionary of how many times the note appears per octave in the song. The “types” key is a dictionary that maps each note type to the number of times that note type appears in the song. Note that any notes not present in the song are also not present in the dictionary. Example: “test.song” 90 song_as_dict(“test.song”) —-> ‘tempo’: 90, ‘tuning’: 440.0, ‘notes’: { ‘D’: {6: 1, 4: 1}, ‘F#’: {6: 2, 7: 2, 2: 1}, ‘A#’: {1: 1}, ‘A’: {2: 1}, “D#’: {2: 1}, ‘E’: {6: 1}, ‘G’: {5: 1}, ‘G#’: {5: 1}, ‘C’: {4: 1}, ‘B’: {2: 1} 440 D6, Whole F#6, Quarter A#1, Half A2, Sixteenth D#2, Eighth F#7, Sixteenth F#7 , Whole D4, Sixteenth E6, Sixteenth G5, Eighth G#5, Half C4, Sixteenth F#2, Sixteenth B2, Sixteenth F#6, Sixteenth ‘types’: { ‘Whole’: 2, ‘Quarter’: 1, ‘Half’: 2, “Sixteenth’: 8, “Eighth’: 2 Show transcribed image text Restrictions • There is exactly one import statement allowed in this project: import random O You are not allowed to import anything else. O You 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: o range(), 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.
song_as_dict(filename) Description: Transforms a song from a file into a dictionary. The information it stores is the number of notes (separated by octaves) and note types that appear in the given song. Parameters: filename (string) the name of the song file to use Return value: A dictionary with four keys: “tempo”, “tuning”, “notes” and “types” The “tempo” key is just the value of the tempo of the song, and the “tuning” key is the value of the tuning frequency of the song. The “notes” key is a dictionary that maps each individual note to another. dictionary of how many times the note appears per octave in the song. The “types” key is a dictionary that maps each note type to the number of times that note type appears in the song. Note that any notes not present in the song are also not present in the dictionary. Example: “test.song” 90 song_as_dict(“test.song”) —-> ‘tempo’: 90, ‘tuning’: 440.0, ‘notes’: { ‘D’: {6: 1, 4: 1}, ‘F#’: {6: 2, 7: 2, 2: 1}, ‘A#’: {1: 1}, ‘A’: {2: 1}, “D#’: {2: 1}, ‘E’: {6: 1}, ‘G’: {5: 1}, ‘G#’: {5: 1}, ‘C’: {4: 1}, ‘B’: {2: 1} 440 D6, Whole F#6, Quarter A#1, Half A2, Sixteenth D#2, Eighth F#7, Sixteenth F#7 , Whole D4, Sixteenth E6, Sixteenth G5, Eighth G#5, Half C4, Sixteenth F#2, Sixteenth B2, Sixteenth F#6, Sixteenth ‘types’: { ‘Whole’: 2, ‘Quarter’: 1, ‘Half’: 2, “Sixteenth’: 8, “Eighth’: 2

Expert Answer


Answer to Restrictions • There is exactly one import statement allowed in this project: import random O You are not allowed to i…

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us