The Big Think

December 23, 2010

Hello World

Filed under: Computing — jasony @ 10:24 pm

Beginning my plow through the Python programming language. Thanks to Sean (and co-worker) for pointing out this free online book. I had just put the book into my Amazon basket when he pointed out the free PDF version. Thanks, Sean!

*update* Just wrote my first program (my blog software won’t indent, but you get the picture):

#this is the number guessing game
import random


print (‘hello! what is your name?’)

number = random.randint(1,20)
print (‘well, ‘ +myName+ ‘, I am thinking of a number between 1 and 20.’)
print (‘You have 6 guesses’)
while guessesTaken < 6: print("Take a guess.")#There are four spaces in front of print. guess=input() guess=int(guess) guessesTaken=guessesTaken+1 if guess < number: print ('your guess is too low.') if guess > number:
print (‘your guess is too high’)

if guess == number:

if guess == number:
guessesTaken = str(guessesTaken)
print (‘Good job, ‘ +myName+ ‘! You guessed my number in ‘ +guessesTaken+ ‘ guesses!’)

if guess != number:
number = str(number)
print (‘Nope. The number I was thinking of was ‘ + number)

Powered by WordPress