[Tutor] Times Tables Program that constantly tells you that you are wrong!
Peter Otten
__peter__ at web.de
Wed Aug 15 04:55:15 EDT 2018
Matthew Polack wrote:
> *Question 1:*
>
> *Why cant the program check if 'answer' variable is correct?*
Change the line
result = "Sorry...you were wrong.
in your script to
result = "Sorry...you were wrong. Expected {!r}, but got {!r}".format(answer, response)
and find out yourself.
Hint: answer in the makeproblem() function is not a global variable.
> lib\tkinter\__init__.py", line 3269, in insert
> self.tk.call((self._w, 'insert', index, chars) + args)
> _tkinter.TclError: bad text index "1"
The first argument of the Text.insert() is a string in a special format. Read
http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/text-index.html
http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/text-methods.html
for the details. You have a mix of one float (which may work by accident) or two integers (which raises an exception).
> *Question 2:*
> Is there a way to centre text within the text frame? I can change the font
> and size...but don't know how to centre it?
I don't know, and I'm too lazy to google ;)
> txt = Text(root, width=35, height=10, wrap=WORD, font=("arial", 24,
> "bold")) txt.grid(row=12, columnspan=2, sticky=EW )
>
>
> *Question 3:*
>
> My 'Score' check idea..may not actually work...haven't been able to get
> that far yet though!
The score variable is not declared global and not initialised. You cannot increment something that doesn't exist.
> Thanks so much for any clues.
>
> - Matthew Polack
>
>
>
>
>
>
>
> Matthew Polack | Teacher
>
>
> [image: Emailbanner3.png]
>
> Trinity Drive | PO Box 822
>
> Horsham Victoria 3402
>
> p. 03 5382 2529 m. 0402456854
>
> e. matthew.polack at htlc.vic.edu.au
>
> w. www.htlc.vic.edu.au
>
More information about the Tutor
mailing list