Python3 in action

This is a screen-shot of my laptop. It’s got a program open that asks the player to guess a number from 1 – 100. After that the computer makes a guess and asks if the answer is higher or lower or the same as the guess. When the computer gets the answer, it tells you how many attempts it took. It’s quite a simple program. I wrote this myself – it was one of the tasks in the book on Python that I am reading.

antiloquax

Advertisements

Tags: , ,

One Response to “Python3 in action”

  1. antiloquax Says:

    We had a look at this today after school at the first meeting of our computer club. We quickly realised that the program couldn’t cope with an invalid input. I added two lines of code:

    else:
    print(“Sorry, I don’t recognise that choice.”)

    This didn’t work at the time – it was just a problem with tabs and spaces for indents not matching up. I now have it running and politely telling me if I type anything other that: “l”, “h” or “y”.

    antiloquax

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: