antiprocess.net

ivuorinen @ Twitter
Ismo
  • ...twitter loading...

Dec22nd07@// game.py

Dec 22nd 07 at 4pm to English · Tags: , ·

My first own functional python script is ready. It’s a simple game.
If you have pointers how to make it better, please do write em. I’m eager to learn.

# -*- coding: cp1252 -*-
import random

running = True
r = random.randrange(65,90)
r_chr = chr(r)
while running:
	print "Numeric value for ASCII '" + r_chr + "'?"
	try:

		a = input("Your answer: ")
		if chr(a) == r_chr:
			print "Correct! " + r_chr + " is", a
			running = False
		else:
			print "Wrong... Try again."
			running = True

	except NameError:
		print "You didn't provide a good numeric value."
	except KeyboardInterrupt:
		print "Shutting down..."
		running = False
		quit()
	except:
		print "Something went wrong..."
		running = False
		quit()

The game: Learn the numerical values of ASCII uppercase letters. — Why? I don’t know.

The 5th day after reading first things about python, 2nd day actually learning and writing it.

Leave a Reply