<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>9 Little Bees</title>
	
	<link>http://9littlebees.com</link>
	<description>Learning how to programme in Python</description>
	<lastBuildDate>Fri, 27 Apr 2012 19:52:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/9littlebees" /><feedburner:info uri="9littlebees" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>9littlebees</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>print “Hello World!” #Getting started with programming</title>
		<link>http://feedproxy.google.com/~r/9littlebees/~3/MOvXIosya1o/</link>
		<comments>http://9littlebees.com/hello-world/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 17:46:06 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://9littlebees.com/?p=1388</guid>
		<description><![CDATA[Well, today marks the start of something new &#8211; today I start learning how to programme. This is something of a departure for me, as I am a keen amateur photographer and this website used to be my photoblog (now...]]></description>
			<content:encoded><![CDATA[<p>Well, today marks the start of something new &#8211; today I start learning how to programme.</p>
<p>This is something of a departure for me, as I am a keen amateur photographer and this website used to be my photoblog (now residing at <a href="http://fotokay.net">fotokay.net</a>).</p>
<p>Anyway, after having spent a lot of time online browsing forum threads, starting new forum threads and reading some excellent tutorials, I&#8217;ve decided that I will start off learning Python (version 2, not 3).  To aid this, I will be following the excellently reviewed book &#8220;Invent Your Own Computer Games with Python&#8221; by Al Sweigart.  It is available as a free PDF from <a href="http://inventwithpython.com/">his website</a>.</p>
<p>Today I have worked through the first 4 chapters, and can say that the syntax in Python is fairly easy to get my head around.  Chapter four has you building your first game, which is simply a &#8220;guess the number&#8221; game.  Here&#8217;s the code for it &#8211; pretty easy to understand!</p>
<pre># This is a guess the number game.
import random

guesses_taken = 0

print "Hello! What is your name?"
my_name = raw_input()

number = random.randint(1,20)
print "Well, " + my_name + ", I am thinking of a number between 1 to 20."

while guesses_taken &lt; 6:
    print "Take a guess."
    guess = raw_input()
    guess = int(guess)

    guesses_taken = guesses_taken + 1

    if guess &lt; number:
        print "Your guess is too low."

    if guess &gt; number:
        print "Your guess is too high."

    if guess == number:
        break

if guess == number:
    guesses_taken = str(guesses_taken)
    print "Good job, " + my_name + "! You guessed my number in " + guesses_taken + " guesses!"

if guess != number:
    number = str(number)
    print "Nope. The number I was thinking of was " + number</pre>
<p>And here is the result when the code is actually run:</p>
<p><img class="alignleft size-full wp-image-1420" title="guess_output" src="http://9littlebees.com/wp-content/uploads/guess_output.jpg" alt="" width="685" height="194" /></p>
<img src="http://feeds.feedburner.com/~r/9littlebees/~4/MOvXIosya1o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://9littlebees.com/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://9littlebees.com/hello-world/</feedburner:origLink></item>
	</channel>
</rss><!-- Served from: 9littlebees.com @ 2012-05-06 13:44:46 by W3 Total Cache -->

