http://wiki.math.bme.hu/history/Informatics2-2021/Lab03?feed=atom&Informatics2-2021/Lab03 - Laptörténet2024-03-28T13:57:41ZAz oldal laptörténete a wikibenMediaWiki 1.18.1http://wiki.math.bme.hu/index.php?title=Informatics2-2021/Lab03&diff=14736&oldid=prevImran, 2021. március 18., 22:38-n2021-03-18T22:38:42Z<p></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Régebbi változat</td>
<td colspan='2' style="background-color: white; color:black;">A lap 2021. március 18., 22:38-kori változata</td>
</tr><tr><td colspan="2" class="diff-lineno">1. sor:</td>
<td colspan="2" class="diff-lineno">1. sor:</td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">[[Informatics2-2021|Home]] </ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= Exercises =</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= Exercises =</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>=== Square List===</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>=== Square List===</div></td></tr>
</table>Imranhttp://wiki.math.bme.hu/index.php?title=Informatics2-2021/Lab03&diff=14648&oldid=prevImran: /* Exercises */2021-02-23T21:50:06Z<p><span class="autocomment">Exercises</span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Régebbi változat</td>
<td colspan='2' style="background-color: white; color:black;">A lap 2021. február 23., 21:50-kori változata</td>
</tr><tr><td colspan="2" class="diff-lineno">1. sor:</td>
<td colspan="2" class="diff-lineno">1. sor:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= Exercises =</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>= Exercises =</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">=== Square List===</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">Write a function that gives square of a list. The function should have one parameter, the list :</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">* It returns square of the list</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">* If the given parameter is not a list, it returns "The input must be a list!"</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>=== Mean nearest ===</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>=== Mean nearest ===</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
</table>Imranhttp://wiki.math.bme.hu/index.php?title=Informatics2-2021/Lab03&diff=14647&oldid=prevImran: /* Pascal */2021-02-23T14:06:44Z<p><span class="autocomment">Pascal</span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Régebbi változat</td>
<td colspan='2' style="background-color: white; color:black;">A lap 2021. február 23., 14:06-kori változata</td>
</tr><tr><td colspan="2" class="diff-lineno">52. sor:</td>
<td colspan="2" class="diff-lineno">52. sor:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>For example the result of <tt>pascal(4)</tt> should be:</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>For example the result of <tt>pascal(4)</tt> should be:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div>     <del class="diffchange diffchange-inline">[</del>[1],</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>     [1],</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>     [1, 1],</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>     [1, 1],</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>     [1, 2, 1],</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>     [1, 2, 1],</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div>     [1, 3, 3, 1<del class="diffchange diffchange-inline">]</del>]</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>     [1, 3, 3, 1]</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Use the fact that a coefficient is the sum of the two elements above it.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>Use the fact that a coefficient is the sum of the two elements above it.</div></td></tr>
</table>Imranhttp://wiki.math.bme.hu/index.php?title=Informatics2-2021/Lab03&diff=14646&oldid=prevImran, 2021. február 23., 08:29-n2021-02-23T08:29:32Z<p></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←Régebbi változat</td>
<td colspan='2' style="background-color: white; color:black;">A lap 2021. február 23., 08:29-kori változata</td>
</tr><tr><td colspan="2" class="diff-lineno">41. sor:</td>
<td colspan="2" class="diff-lineno">41. sor:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* return the string <tt>"Hard"</tt> if the number of consonants are more (or equal) than twice the number of vowels.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* return the string <tt>"Hard"</tt> if the number of consonants are more (or equal) than twice the number of vowels.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* return <tt>"Easy"</tt> otherwise.</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>* return <tt>"Easy"</tt> otherwise.</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">=== Food courses ===</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">Suppose you have a really strict diet and you have a given number of calories what you should eat for dinner.</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">You walk in a restaurant and they have the menu of soups and main dishes. Every item on the menu has a calorie value.</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">Can you choose the right dishes to exactly match your calorie intake?</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">Write a python function</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">* called <tt>dishes</tt></del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">* that have three parameters:</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">** ''calorie'', the number of calories you should eat</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">** ''soups'', a list containing calorie values for the soups</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">** ''mains'', a list containing calorie values for the main dishes</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del style="color: red; font-weight: bold; text-decoration: none;">* You should return <tt>True</tt> if there is a two-course meal that fits your diet (<tt>False</tt> otherwise).</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>=== Pascal ===</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>=== Pascal ===</div></td></tr>
</table>Imranhttp://wiki.math.bme.hu/index.php?title=Informatics2-2021/Lab03&diff=14644&oldid=prevImran: Új oldal, tartalma: „= Exercises = === Mean nearest === Write a function that finds an element in a list which is the nearest to the mean of the list. There should be one parameter, the l…”2021-02-23T03:47:53Z<p>Új oldal, tartalma: „= Exercises = === Mean nearest === Write a function that finds an element in a list which is the nearest to the mean of the list. There should be one parameter, the l…”</p>
<p><b>Új lap</b></p><div>= Exercises =<br />
<br />
=== Mean nearest ===<br />
<br />
Write a function that finds an element in a list which is the nearest to the mean of the list.<br />
There should be one parameter, the list.<br />
<br />
=== Increasing sublists ===<br />
<br />
Write a function that finds increasing sublists with a given length within a given list.<br />
The function should have two parameters:<br />
* a list ''l''<br />
* and a natural number ''n''<br />
* return the list of ''n''-long increasing sublists of ''l''<br />
<br />
Break down to subtasks:<br />
* first return the list of all ''n''-long sublists of ''l''<br />
* Check whether a sublist is increasing<br />
<br />
=== Name conflict ===<br />
We are throwing a party and there are a lots of unknown people there.<br />
We write their names in a list.<br />
Write a python function that decides whether there is a duplicate in the names (two person with the same name).<br />
<br />
The function should have one parameter: the list of names.<br />
<br />
Return <tt>True</tt> if there are at least two people with the same name, <tt>False</tt> is all the names are unique.<br />
<br />
'''Hint:'''<br />
<br />
Mind that do not compare ones name to itself, only to other's names.<br />
<br />
=== Pronunciation ===<br />
In Hungarian there are a lots of vowels and some words are hard to pronounce if there are a lots of consonants in them.<br />
For example ''"elorozza"'' has a good number of vowels, but the Slovakian ''"zmrzlina"'' has too many consonants.<br />
<br />
Write a python function that decides whether a word has too many consonants or not.<br />
<br />
* Call the function <tt>pronunciation</tt><br />
* with one parameter: ''word'', the word in question<br />
* return the string <tt>"Hard"</tt> if the number of consonants are more (or equal) than twice the number of vowels.<br />
* return <tt>"Easy"</tt> otherwise.<br />
<br />
=== Food courses ===<br />
Suppose you have a really strict diet and you have a given number of calories what you should eat for dinner.<br />
You walk in a restaurant and they have the menu of soups and main dishes. Every item on the menu has a calorie value.<br />
<br />
Can you choose the right dishes to exactly match your calorie intake?<br />
<br />
Write a python function<br />
* called <tt>dishes</tt><br />
* that have three parameters:<br />
** ''calorie'', the number of calories you should eat<br />
** ''soups'', a list containing calorie values for the soups<br />
** ''mains'', a list containing calorie values for the main dishes<br />
* You should return <tt>True</tt> if there is a two-course meal that fits your diet (<tt>False</tt> otherwise).<br />
<br />
=== Pascal ===<br />
The Pascal triangle consist of binomial coefficients, find details on [https://en.wikipedia.org/wiki/Pascal%27s_triangle Wikipedia].<br />
<br />
Write a function that calculates some lines of the triangle and returns it as a list of lists.<br />
First list is <tt>[1]</tt>, second is of length 2, and so on.<br />
<br />
The function should have one parameter: ''n'', the number of rows to calculate.<br />
<br />
For example the result of <tt>pascal(4)</tt> should be:<br />
<br />
[[1],<br />
[1, 1],<br />
[1, 2, 1],<br />
[1, 3, 3, 1]]<br />
<br />
Use the fact that a coefficient is the sum of the two elements above it.<br />
<br />
=== Replacement ===<br />
Write a function with two parameters: ''word'' is a string, and ''replaces'' a list of pairs where every pair is a number-character pair, like: <tt>(n, c)</tt>.<br />
You should replace the characters in ''word'' according to the ''replaces''. On pair represents that you should replace the ''n''<sup>th</sup> character to the new letter ''c''.<br />
<br />
Return the new word after you performed the replacements.<br />
<br />
For example replace <tt>[(0, 'm'), (2, 'm'), (3, 'm')]</tt> in <tt>"puppy"</tt> you get <tt>mummy</tt>.<br />
<br />
=== Name generator ===<br />
You write a computer game where you have to choose name of your player. The name consists of a first name and a last name where the names come from a given list of possibilities.<br />
<br />
Generate all the possible names composed from the list of first names and list of last names.</div>Imran