Nivå och poängvärde: | A 80 |
---|---|
Kort beskrivning: | Vi skapar en funktion |
Vad vi lär oss: | Att skapa egna simpla funktioner. |
Frihet i implementationen: | Liten. Här följer man instruktionerna till punkt och pricka. |
Realism: | Medel. Funktioner är allmänt använda byggnadsstenar i program. |
Utmaning: | Lätt, om man kan läsa innantill. |
Arbetsmängd: | Lätt. De flesta klarar sig på under en timme. |
Vi fortsätter på "Hänga Gubbe"-spelet.
Skapa ett nytt projekt (eller fortsätt på det förra) och i det modulen hanging_man.py.
choose
-funktionen:
(tom rad) Options: l guess a letter w guess the word i instructions q quit (tom rad) Give your choice (l/w/i/q): w
instructions
-funktionen:
I'm thinking about a word and your task is to guess that word by giving letters. If you give a correct letter, all instances of the letter in the word, will be shown. If you give a wrong letter, you are one step closer to be hanging. Also, if you give a letter that has already been used, hanging is closer. Underscores in the word represent missing letters. If you think, that you know the word before the last guess is used, you can give it. When the picture is like following, your time has ended. (tom rad) (tom rad) +-----+ | | | O | /|\ | / \ +------- |(tom rad) betyder alltså att det bara finns ett radbyte på den raden.
Lämna in filen hanging_man.py i Goblin.