Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Creating simple classes and instantiating objects. Including attributes and methods to classes. In the blank trinket given, define an empty class named Circle and instantiate

Creating simple classes and instantiating objects. Including attributes and methods to classes.

In the blank trinket given, define an empty class named Circle and instantiate an object of this class.

Include a method named setRadius() to set the attribute radius of Circle. Call this method for the object created in (i).

Include methods to calculate area and perimeter of circle. Call these methods for objects created in (i).

Inheritance. In this activity, we will create a parent class MediaFile and two subclasses, MusicFile and VideoFile, that are related to MediaFile by single inheritance.

In the blank trinket file, create a class MediaFile that has two attributes: title and duration. It has three methods: setTitle, setDuration and play(). Methods setTitle() and setDuration() are used to set the attributes title and duration respectively. The play() method prints a statement in the form: playing file with duration <duration> mins.</p> <p> </p> <p>In the same trinket file, create class MusicFile using its parent class, MediaFile. Class MusicFile also consists of attribute artist that stores the name of the artist. Include a method setArtist() to set attribute artist. play() method of this class prints: playing song <title> by <artist> with duration <duration> mins.</p> <p> </p> <p>In the same trinket file, create class VideoFile using its parent class, MediaFile. Class VideoFile also consists of attribute quality that stores the name of the picture quality (SD, HD, etc). Include a method setQuality() to set attribute quality. play() method of this class prints: playing video <title> in <quality> with duration <duration> mins.</p> <p> </p> <p>Instantiate a MusicFile object. Set appropriate values using its methods and call the play() method.</p> <p> </p> <p>Instantiate a VideoFile object. Set appropriate values using its methods and call the play() method.</p> <p> </p> <p> </p> <p>Using super() method.</p> <p>The given code defines classes rectangle and square. Square inherits a few properties of rectangles. Instantiate a Square object and use the calArea() and calPerimter() methods to display the area and perimeter of the object.</p> <p> </p> <p>class Rectangle: </p> <p> def set(self, length, breadth): </p> <p> self.length=length </p> <p> self.breadth=breadth</p> <p> def calArea(self): </p> <p> return self.length*self.breadth</p> <p> def calPerimeter(self):</p> <p> return 2*(self.length+self.breadth)</p> <p> </p> <p>class Square(Rectangle):</p> <p> def set(self, side):</p> <p> super().set(side, side)</p> <p> </p> <p>The surface area of the cube is equal to 6 times its face area. Face area is the area of the square. Create class Cube by inheriting Square class. Within the class, create a method to calculate the surface area of a cube. Implement super() method in your method.</p> <p> </p> <p>The volume of a cube can be stated as the face area times the side of a cube. Within the class definition of Cube, include a method to calculate volume of a cube. Implement super() function in your method.</p> <p> </p> <p>Instantiate a Cube object and write statements to print its surface area and volume.</p> </h2> </section> <section class="answerHolder"> <div class="answerHolderHeader"> <div class="answer-heading"> <h2>Step by Step Solution</h2> </div> <div class="answerReviews"> <div class="starReview"> <div class="starIcon"> </div> <div class="starText"> </div> </div> </div> </div> <div class="answerSteps"> <p>There are <span>3</span> Steps involved in it</p> <div class="step"> <h3>Step: 1</h3> <img src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-text-image.webp" width="759" height="271" alt="blur-text-image" loading="lazy" decoding="async" fetchpriority="low"> <div class="step1Popup"> <h3>Get Instant Access with AI-Powered Solutions</h3> <p>See step-by-step solutions with expert insights and AI powered tools for academic success</p> <button class="view_solution_btn step1PopupButton">View Solution</button> </div> </div> <div class="step"> <h3 class="accordion">Step: 2</h3> <div class="panel"> <img src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp" width="975" height="120" alt="blur-text-image" loading="lazy" decoding="async" fetchpriority="low"> <button class="view_solution_btn stepPopupButton">Sign Up to view</button> </div> </div> <div class="step"> <h3 class="accordion">Step: 3</h3> <div class="panel"> <img src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp" width="975" height="120" alt="blur-text-image" loading="lazy" decoding="async" fetchpriority="low"> <button class="view_solution_btn stepPopupButton">Sign Up to view</button> </div> </div> </div> </section> </div> <div class="expertRight"> <section class="AIRedirect"> <div class="AIHolder"> <h2>Ace Your Homework with AI</h2> <p>Get the answers you need in no time with our AI-driven, step-by-step assistance</p> <a class="AILink" href="/ask_ai">Get Started</a> </div> </section> </div> </section> <section class="relatedQuestion"> <div class="relatedQuestionHolder"> <h4>Students also viewed these Databases questions</h4> <div class="relatedQuestionSliderHolder"> <div class="relatedQuestionCart "> <div class="relatedQuestionCartHeader"> <h3>Question</h3> </div> <a class="relatedQuestionText" href="/study-help/psychology-2e/5-discuss-and-explain-the-ekkekakis-dualmode-hypothesis-as-it-1988443" > 5. Discuss and explain the Ekkekakis dualmode hypothesis as it relates to exercise intensity and psychological affect. How does this model help us understand exercise intensity and psychological... </a> <div class="relatedQuestionCartFooter"> <div class="relatedHistory"> <p> Answered: <span>1 week ago</span> </p> </div> </div> </div> <div class="relatedQuestionCart "> <div class="relatedQuestionCartHeader"> <h3>Question</h3> <div class="relatedStarRating"> <span class="star active">★</span><span class="star active">★</span><span class="star active">★</span><span class="star">★</span><span class="star">★</span> </div> </div> <a class="relatedQuestionText" href="/the-national-credit-union-has-250000-available-to-invest-in" > The National Credit Union has $250,000 available to invest in a 12-month commitment. The money can be placed in Treasury notes yielding an 8% return or in municipal bonds at an average rate of return... </a> <div class="relatedQuestionCartFooter"> <div class="relatedHistory"> <p> Answered: <span>1 week ago</span> </p> </div> </div> </div> <div class="relatedQuestionCart "> <div class="relatedQuestionCartHeader"> <h3>Question</h3> <div class="relatedStarRating"> <span class="star active">★</span><span class="star active">★</span><span class="star active">★</span><span class="star">★</span><span class="star">★</span> </div> </div> <a class="relatedQuestionText" href="/study-help/questions/under-personal-jurisdiction-courts-have-jurisdiction-over-group-of-answer-10022437" > Under personal jurisdiction, courts have jurisdiction over Group of answer choices Those who consent to jurisdiction in that state People who reside in that state Those found in their state and... </a> <div class="relatedQuestionCartFooter"> <div class="relatedHistory"> <p> Answered: <span>1 week ago</span> </p> </div> </div> </div> <div class="relatedQuestionCart "> <div class="relatedQuestionCartHeader"> <h3>Question</h3> <div class="relatedStarRating"> <span class="star active">★</span><span class="star active">★</span><span class="star active">★</span><span class="star">★</span><span class="star">★</span> </div> </div> <a class="relatedQuestionText" href="/study-help/questions/is-the-process-by-which-a-consumer-discards-an-5564856" > _____ is the process by which a consumer discards an offering. a. Comprehension b. Attention c. Habituation d. Disposition e. Diffusion </a> <div class="relatedQuestionCartFooter"> <div class="relatedHistory"> <p> Answered: <span>1 week ago</span> </p> </div> </div> </div> <div class="relatedQuestionCart "> <div class="relatedQuestionCartHeader"> <h3>Question</h3> <div class="relatedStarRating"> <span class="star active">★</span><span class="star active">★</span><span class="star active">★</span><span class="star">★</span><span class="star">★</span> </div> </div> <a class="relatedQuestionText" href="/study-help/questions/case-study-1-read-the-case-below-and-answer-the-1003004" > CASE STUDY 1 Read the case below and answer the questions that follow: [10] John applied for the post of supervisor at Amazing Textiles (Pty) Ltd, a textile factory. At his final interview he made it... </a> <div class="relatedQuestionCartFooter"> <div class="relatedHistory"> <p> Answered: <span>1 week ago</span> </p> </div> </div> </div> <div class="relatedQuestionCart "> <div class="relatedQuestionCartHeader"> <h3>Question</h3> <div class="relatedStarRating"> <span class="star active">★</span><span class="star active">★</span><span class="star active">★</span><span class="star">★</span><span class="star">★</span> </div> </div> <a class="relatedQuestionText" href="/study-help/questions/case-study-in-the-highly-competitive-world-of-music-streaming-1002451" > Case study In the highly competitive world of music streaming, Pandora chose to maintain a very employee centric model of work. The organization was proud of several HR initiatives which it thought... </a> <div class="relatedQuestionCartFooter"> <div class="relatedHistory"> <p> Answered: <span>1 week ago</span> </p> </div> </div> </div> <div class="relatedQuestionCart "> <div class="relatedQuestionCartHeader"> <h3>Question</h3> <div class="relatedStarRating"> <span class="star active">★</span><span class="star active">★</span><span class="star active">★</span><span class="star">★</span><span class="star">★</span> </div> </div> <a class="relatedQuestionText" href="/study-help/questions/an-organisation-chart-graphically-depicts-an-organisation-structure-it-shows-1003362" > An organisation chart graphically depicts an organisation structure. It shows how the work of different people in the organisation coordinated and integrated ( Chandler , 1 9 8 8 ) . Construction... </a> <div class="relatedQuestionCartFooter"> <div class="relatedHistory"> <p> Answered: <span>1 week ago</span> </p> </div> </div> </div> <div class="relatedQuestionCart "> <div class="relatedQuestionCartHeader"> <h3>Question</h3> <div class="relatedStarRating"> <span class="star active">★</span><span class="star active">★</span><span class="star active">★</span><span class="star">★</span><span class="star">★</span> </div> </div> <a class="relatedQuestionText" href="/study-help/questions/1-as-the-airbus-a380-is-widely-considered-a-technological-1002966" > 1. AS THE AIRBUS A-380 IS WIDELY CONSIDERED A TECHNOLOGICAL MARVEL, IT IS HARD TO COMPREHEND WHY THE OF SALES OF THIS AERONAUTICAL PRODUCT IS DECLINING. HAVING BUILT A STATE-OF-THE-ART AIRCRAFT, THEN... </a> <div class="relatedQuestionCartFooter"> <div class="relatedHistory"> <p> Answered: <span>1 week ago</span> </p> </div> </div> </div> <div class="relatedQuestionCart "> <div class="relatedQuestionCartHeader"> <h3>Question</h3> <div class="relatedStarRating"> <span class="star active">★</span><span class="star active">★</span><span class="star active">★</span><span class="star">★</span><span class="star">★</span> </div> </div> <a class="relatedQuestionText" href="/study-help/questions/john-wozniak-works-as-a-cashier-at-a-playground-equipment-1002738" > John Wozniak works as a cashier at a playground equipment retail outlet. With no supervisor approval required, John was able to process fictitious refunds for customer sales. What scheme is this?... </a> <div class="relatedQuestionCartFooter"> <div class="relatedHistory"> <p> Answered: <span>1 week ago</span> </p> </div> </div> </div> </div> </div> </section> <hr class="expert-separator"> <section class="next-previous-button"> <div class="navigationButtons" bis_skin_checked="1"> <a class="previousQuestionButton" href="/study-help/questions/a-n-q-entity-can-be-either-9291416">Previous Question</a> <a class="nextQuestionButton" href="/study-help/questions/complete-question-5-when-calculating-the-debt-ratio-assume-debt-9291418">Next Question</a> </div> </section> </div> <div class="promo items-center justify-center hidden" style="margin-left:-15px;"> <div class="app_promo"> <div class="app_promo_headline"> <img class="app_promo_icon" alt="Mobile App Logo" width="40" height="40" loading="lazy" src="includes/images/mobile/finalLogo.png"> <p class="app_promo_title font-sans items-center">View Answer in SolutionInn App</p> </div> <button class="app_promo_action redirection question_open_url='q_id=9291417&q_type=2'"> Download on the App Store </button> <button class="btn btn-default app_promo_dismiss"> Continue with the mobile website </button> </div> </div> </main> </div> <div class="blank-portion"></div> <footer> <div class="container footerHolder"> <div class="footerLinksFlex"> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-6"> <p>Services</p> <ul> <li><a href="/site-map">Sitemap</a></li> <li><a href="/fun/">Fun</a></li> <li><a href="/study-help/definitions">Definitions</a></li> <li><a href="/tutors/become-a-tutor">Become Tutor</a></li> <li><a href="/study-help/categories">Study Help Categories</a></li> <li><a href="/study-help/latest-questions">Recent Questions</a></li> <li><a href="/study-help/questions-and-answers">Expert Questions</a></li> </ul> </div> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-6"> <p>Company Info</p> <ul> <li><a href="/security">Security</a></li> <li><a href="/copyrights">Copyrights</a></li> <li><a href="/privacy">Privacy Policy</a></li> <li><a href="/conditions">Terms & Conditions</a></li> <li><a href="/solutioninn-fee">SolutionInn Fee</a></li> <li><a href="/scholarships">Scholarship</a></li> </ul> </div> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-6"> <p>Get In Touch</p> <ul> <li><a href="/about-us">About Us</a></li> <li><a href="/support">Contact Us</a></li> <li><a href="/career">Career</a></li> <li><a href="/jobs">Jobs</a></li> <li><a href="/support">FAQ</a></li> <li><a href="/campus-ambassador-program">Campus Ambassador</a></li> </ul> </div> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-12"> <p>Secure Payment</p> <div class="footerAppDownloadRow"> <div class="downloadLinkHolder"> <img src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/rewamp/common/footer/secure_payment_method.png" class="img-fluid mb-3" width="243" height="28" alt="payment-verified-icon" loading="lazy"> </div> </div> <p>Download Our App</p> <div class="footerAppDownloadRow"> <div class="downloadLinkHolder mobileAppDownload col-md-6 col-lg-6 col-sm-6 col-6"> <img style="cursor:pointer;" src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/rewamp/home_page/google-play-svg.svg" alt="SolutionInn - Study Help App for Android" width="116" height="40" class="img-fluid mb-3 redirection " app_type="1" loading="lazy"> </div> <div class="downloadLinkHolder mobileAppDownload col-md-6 col-lg-6 col-sm-6 col-6"> <img style="cursor:pointer;" src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/rewamp/home_page/apple-store-download-icon.svg" alt="SolutionInn - Study Help App for iOS" width="116" height="40" class="img-fluid mb-3 redirection" app_type="2" loading="lazy"> </div> </div> </div> </div> </div> <div class="footer-bottom"> <p>© 2024 SolutionInn. All Rights Reserved</p> </div></footer> <script defer> window.addEventListener("load",function(){jQuery(document).ready(function(t){t.ajax({type:"POST",url:"/",data:{trackUserActivity:!0,reqUri:document.URL,referer:document.referrer},success:function(t){}})})},!1),window.addEventListener("load",function(){jQuery(document).ready(function(t){t.ajax({type:"POST",url:"/",data:{insertCrawler:!0,reqUri:document.URL,parseTime:"0.056",queryTime:"0.01654768548584",queryCount:"30"},success:function(t){}})})},!1),window.addEventListener("load",function(){jQuery(document).ready(function(){function t(t="",n=!1){var i="itms-apps://itunes.apple.com/app/id6462455425",e="openApp://action?"+t;isAndroid()?(setTimeout(function(){return window.location="market://details?id=com.solutioninn.studyhelp",!1},25),window.location=e):isIOS()?(setTimeout(function(){return window.location=i,!1},25),window.location=e):(i="https://apps.apple.com/in/app/id6462455425",n&&(i="https://play.google.com/store/apps/details?id=com.solutioninn.studyhelp"),window.open("about:blank","_blank").location.href=i)}jQuery("#appModal").modal("show"),jQuery(".download-app-btn").click(function(){t(jQuery(this).attr("question_open_url"))}),jQuery(".redirection").click(function(){var n=jQuery(this).attr("question_open_url"),i=jQuery(this).attr("app_type");void 0!=n?1==i?t(n,!0):t(n,!1):1==i?t("",!0):t("",!1)}),jQuery(".app-notification-close").click(function(){jQuery(".app-notification-section").css("visibility","hidden");var t=new FormData;t.append("hide_notification",!0),jQuery.ajax({type:"POST",url:"/",data:t,cache:!1,contentType:!1,processData:!1,beforeSend:function(){},success:function(t){location.reload()}})})})},!1); </script> </body> </html>