Linux Today: Linux News On Internet Time.
Search Linux Today
Linux News Sections:  Developer -  High Performance -  Infrastructure -  IT Management -  Security -  Storage -
Linux Today Navigation
LT Home
Contribute
Contribute
Link to Us
Linux Jobs


Top White Papers

More on LinuxToday


Python4Kids New Tutorial: Trivia Game Part 2

Sep 22, 2010, 16:33 (0 Talkback[s])
(Other stories by Brendan Scott)

[ Thanks to Brendan Scott for this link. ]

"ARTHUR: He is the keeper of the Bridge of Death. He asks each traveler five questions–
GALAHAD: Three questions.
ARTHUR: Three questions. He who answers the five questions–
GALAHAD: Three questions.
ARTHUR: Three questions may cross in safety.
ROBIN: What if you get a question wrong?
ARTHUR: Then you are cast into the Gorge of Eternal Peril. (At scene 23)

"In the previous tutorial we defined a function to ask a question. The question was sent to the function as an argument and had the type list. The question itself was stored in index number 0 of the list (that is, the first entry) and the correct answer was stored at index number 1 of the list. The homework for the last tutorial was to work out why this was bad. Did you work it out?

"The problem with this is that, the correct answer is always at the same place. So if someone was playing the game, they would just answer '0′ all the time and always get the right answer. So, we're going to need to find some way of randomising the answers. However, when we randomise them we also need to remember which is the correct one"

Complete Story

Related Stories: