Getting Started . A simple number guessing game.

To create code we need to think what we are trying to achieve.

A simple program to get our teeth into is a number guessing game.  The computer picks a random number and we try to guess it. The computer tells us if we are too high or too low.  When we guess it it tells us we have got it correct

So lets come up with a plan

Lets have a deeper look at the if statements.

Lets code it in scratch to see we have the logic right. This can help with the transition from a drag and drop language to a text based one.  Also scratch is a bit like sudo code and allows us to test an idea.

Here is the SCRATCH file

https://www.dropbox.com/s/413fz78zd7vh2fv/number_guessing_game.sb2?dl=0

Now we understand the problem, lets code it in Python

OK, It works, but can we improve it ?

Here is the Python File

https://www.dropbox.com/s/t0aa8cnthtnmfhe/number_guessing_game.py?dl=0

Advertisements

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s