<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1476" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT color=#000080>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000>Hello
list!</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT
color=#000000></FONT> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000>I have
started teaching Python to a group of High School students. I set them the
"Guess the Number" game as a GUI as an assignment. One of the students has
passed in some script that is foreign to any tutorial work we have done.
Some of it is below. Does anyone recognise it? Can you tell me where it would
have been downloaded from? I have searched for scripted guess the number games,
but there are thousands of them - except for a Python version. </FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT
color=#000000></FONT> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000>If my student
has plagiarised - I need to know.</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT
color=#000000></FONT> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000>TIA
Diana</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT
color=#000000></FONT> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT
color=#000000></FONT> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000>from Tkinter
import *</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000>from whrandom
import *</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT
color=#000000> <?xml:namespace prefix = o ns =
"urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT
color=#000000> <o:p></o:p></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000>class rand:
</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>def __init__(self, low,
high):<SPAN style="mso-spacerun: yes"> </SPAN>#whrandom number is
made here</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>self.ro =
whrandom()</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>self.num =
self.ro.randint(low, high)</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT
color=#000000> <o:p></o:p></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>def number(self):<SPAN
style="mso-spacerun: yes">
</SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>return
self.num</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT
color=#000000> <o:p></o:p></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>def set(self):<SPAN
style="mso-spacerun: yes">
</SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>self.num =
self.ro.randint(low, high)</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT
color=#000000> <o:p></o:p></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000>#this part
evaluates the users guess</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000>def
evaluate_ans(guess_str, whrandom, low_str, high_str, guess_left, \</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes">
</SPAN>guess_eval_str, yg_label):</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>guesses_left =
int(guess_left.get())<SPAN style="mso-spacerun: yes">
</SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>guesses_left = guesses_left -
1</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes">
</SPAN>guess_left.set(str(guesses_left))</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>guess =
int(guess_str.get())</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>if guess ==
whrandom.number():<SPAN
style="mso-spacerun: yes">
</SPAN>#User has guessed the number.</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes">
</SPAN>guess_eval_str.set("correct")</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes">
</SPAN>play_agn.configure(state=NORMAL)</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>else:<SPAN
style="mso-spacerun: yes">
</SPAN>#User has not guessed the number.</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>if guess <
whrandom.number():<SPAN
style="mso-spacerun: yes">
</SPAN>#Guess is too low.</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes">
</SPAN>low_str.set(str(guess))</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes">
</SPAN>guess_eval_str.set("too low")</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>elif guess >
whrandom.number():<SPAN
style="mso-spacerun: yes">
</SPAN>#Guess is too high.</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes">
</SPAN>high_str.set(str(guess))</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes">
</SPAN>guess_eval_str.set("too high")</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes">
</SPAN>guess_str.set("")</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>if guesses_left
== 0:<SPAN
style="mso-spacerun: yes">
</SPAN>#User has no guesses left.</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes">
</SPAN>yg_label.configure(text="Correct answer:")</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes">
</SPAN>guess_eval_str.set(str(whrandom.number()))</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes">
</SPAN>play_agn.configure(state=NORMAL)</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>return</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT
color=#000000> <o:p></o:p></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000>#Reset
variables for next game</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000>def
reset(whrandom,play_agn, low_str, high_str, guess_left, guess_str, \</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes">
</SPAN>yg_label, guess_eval_str, low, high):</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes">
</SPAN>play_agn.configure(state=DISABLED)</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>whrandom.set()</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>low_str.set(str(low -
1))</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT color=#000000><SPAN
style="mso-spacerun: yes"> </SPAN>high_str.set(str(high +
1))</FONT></P></FONT></DIV></BODY></HTML>