Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following classes, FileExtensionError and AudioFile: In [7]: class FileExtensionError( Exception ): pass class AudioFile: A class for representing a generic audio file

Consider the following classes, FileExtensionError and AudioFile:

In [7]:

 
class FileExtensionError( Exception ):
 pass
 
class AudioFile:
 """
 A class for representing a generic audio file
 """
 def __init__( self, filepath ):
 if not filepath.endswith( self.extension ):
 raise FileExtensionError( "File {filepath} does not have the expected extension ({self.extension})" )
 self.filepath = filepath

Now define the following classes as subclasses of AudioFile:

WAV_File

AIFF_File

FLAC_File

OGG_File

MP3_File

where each subclass defines a class variable named extension that specifies the expected file extension for the particular audio file that subclass represents and a play( self ) method that pretends to play the audio content in the specified file path. Just like the textbook example, all you need to do is to print out a message that informs the user that the particular file is being played.

WRITE YOUR CODE BELOW

In [6]:

 
#
#
#
# YOUR CODE GOES HERE
#
#
#

Create different numbers of files from each of the above file formats, and add these to a list. You can use the random module to randomize how many of each audio types you wish to create.

Run a for-loop to play each audio file

WRITE YOUR CODE BELOW

In [6]:

 
#
#
#
# YOUR CODE GOES HERE
#
#
#

QUESTION 2

Following the specifications in Question 1 above, create three (3) new audio file format classes with the following names:

WMA_File

PCM_File

AAC_File

WRITE YOUR CODE BELOW

In [6]:

 
#
#
#
# YOUR CODE GOES HERE
#
#
#

Create different numbers of files from each of the above file formats, and add these to a list. You can use the random module to randomize how many of each audio types you wish to create.

Run a for-loop to play each audio file

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

Realize 5-32 line decoder using 3-8 line 74 * 138 decoders

Answered: 1 week ago

Question

What is job enlargement ?

Answered: 1 week ago

Question

what is the most common cause of preterm birth in twin pregnancies?

Answered: 1 week ago

Question

Which diagnostic test is most commonly used to confirm PROM?

Answered: 1 week ago

Question

What is the hallmark clinical feature of a molar pregnancy?

Answered: 1 week ago