polymorphism we were introduced to polymorphism in object-oriented design it is fancy name describing simple conceptdifferent behaviors happen depending on which subclass is being usedwithout having to explicitly know what the subclass actually is as an exampleimagine program that plays audio files media player might need to load an audiofile object and then play it we' put play(method on the objectwhich is responsible for decompressing or extracting the audio and routing it to the sound card and speakers the act of playing an audiofile could feasibly be as simple asaudio_file play(howeverthe process of decompressing and extracting an audio file is very different for different types of files the wav files are stored uncompressedwhile mp wmaand ogg files all have totally different compression algorithms we can use inheritance with polymorphism to simplify the design each type of file can be represented by different subclass of audiofilefor examplewavfilemp file each of these would have play(methodbut that method would be implemented differently for each file to ensure the correct extraction procedure is followed the media player object would never need to know which subclass of audiofile it is referring toit just calls play(and polymorphically lets the object take care of the actual details of playing let' look at quick skeleton showing how this might lookclass audiofiledef __init__(selffilename)if not filename endswith(self ext)raise exception("invalid file format"self filename filename class mp file(audiofile)ext "mp def play(self)print("playing {as mp format(self filename)class wavfile(audiofile)ext "wavdef play(self)