-
Notifications
You must be signed in to change notification settings - Fork 0
/
task.html
19 lines (19 loc) · 2.1 KB
/
task.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<h2>Bittersweet occasion</h2>
<html>
<head></head>
<body>
<p>Mysterious things have happened on the Hogwarts Express! Someone enchanted a food trolley and all the goodies got mixed up on the shelves. While the trolley witch is looking for the culprit, you will place <code class="java">Drinks</code>, <code class="java">Pastry</code> and <code class="java">Sweets</code> on three respective shelves.</p>
<p>These base classes have various children, for example, <code class="java">PumpkinJuice</code> inherits from <code class="java">Drinks</code>. Write a function that finds a parent class for an <strong>unknown class</strong> stored in the variable <code class="java">child</code> and <strong>prints out</strong> the parent's name.</p>
<p>Note: all these classes are already created, you don't need to do that. You only need to work with the <code class="java">child</code>.</p>
<p><button class="btn-sm btn-outline-secondary" onclick="getElementById('hint-798').style.display='inline'"> Hint </button> </p>
<div id="hint-798" style="display:none;">
You can use the
<code class="java">issubclass()</code> function to check is a particular class is the parent class.
</div>
<p></p>
</body>
</html><br><b>Sample Input:</b><br><pre><code class="language-no-highlight">PumpkinJuice</code></pre><br><b>Sample Output:</b><br><pre><code class="language-no-highlight">Drinks</code></pre><br><br><b>Sample Input:</b><br><pre><code class="language-no-highlight">CauldronCake</code></pre><br><b>Sample Output:</b><br><pre><code class="language-no-highlight">Pastry</code></pre><br><br><b>Sample Input:</b><br><pre><code class="language-no-highlight">ChocolateFrog</code></pre><br><b>Sample Output:</b><br><pre><code class="language-no-highlight">Sweets</code></pre><br><br><br><font color="gray">Memory limit: 256 MB</font><br><font color="gray">Time limit: 15 seconds</font><br><br>
<b>Caution</b><br><br>
You may see errors in your code or execution results due to missing context. Don’t worry about it, just write the solution and press Check.
<br><br>
<a href="https://hyperskill.org/learn/step/7235">Show topic summary</a>