[Tutor] Help!!

Alan Gauld alan.gauld at yahoo.co.uk
Tue Sep 27 04:36:12 EDT 2016


On 26/09/16 23:50, Shooby Herrmann wrote:

> I am using JES.  

I've never heard of JES and know nothing about it.
Fortunately it doesn't look like this problem has much
to do with JES so that's not a problem this time...

However in future when you submit a question (whether
on this list or anywhere else) it will help immensely
if you tell us what the problem is. What output did
you expect? What did you get?

If you get an error show us the full error message.
Also tell us the Python version and OS you are using.
It all helps us to help you.

In this case it looks like a basic error so we can
probably help without the extra details...

> #The purpose of this assignment is to give you practice in function calls
> and if statements. Your program will have the user
> #to draw a random circle and a random rectangle and to guess which shape has
> more pixels. It will time how long the user
> #takes to do this and will connect the circle, the rectangle, and the
> outline of the picture with colored lines. 

<snip>all the drawing stuff</snip>

>   #Ask the user, "Which one has more pixels (type 'r' or 'c')?"
> 
>   info= requestString("Which one has more pixels? (type r or c).")
> 

So info will contain a character - either 'r' or 'c'

>   if info== (numPxRectangle >= numPxCircle) :

But you are comparing that character to the result of
a boolean comparison. Basically you are asking one of:

if 'c' == True:
if 'c' == False:
if 'r' == True:
if 'r' == False:

None of which makes much sense, so Python returns
False in every case.

>     showInformation("Congradulations!")

So that line never gets executed.

You need to change the code so you can determine whether
the correct answer is 'c' or 'r' and then compare that
to the users input.

Also notice you were asked to time the user, you still need
to add code for that. But for now, focus on getting the
logic bit right.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list