Here's a little math program I put together in Python.
I just started learning about programming in general a few days ago so I'm quite proud of this little program.
#The Mathalator 3000
#Author: Steingrimur Jonsson
#Date: 28. 09. 2008
from random import randint
scoreCount = 0
qCount = 0
nOfQs = 0
frust = 0
print "Welcome to the mathalator 3000!\n"
print "How many questions would you like?\n(only up to 50)\n"
while nOfQs == 0 or nOfQs < 0 or nOfQs > 50:
nOfQs = int(raw_input(""))
print ""
if nOfQs > (50 or nOfQs < 0) and frust >= 6:
print "Alright, that's it! Get out!"
exit()
elif nOfQs > (50 or nOfQs < 0) and frust >= 3:
frust += 1
print "You're really starting to get on my nerves. Just pick a valid number."
elif nOfQs > 50 or nOfQs < 0:
frust += 1
print "I'm afraid I can't let you do that. Please pick another number.\n"
else:
print "Alrighty, let's get this started.\n"
while qCount < nOfQs:
rand = randint(1,3)
if rand == 1:
qCount += 1
x = randint(1,100)
y = randint(1,100)
print "What is %d %s %d\n" % (x,"+",y)
answer = int(raw_input(""))
if answer == x+y:
scoreCount += 1
print "That is correct!\n"
elif answer != x+y:
print "That is not correct.\n"
elif rand == 2:
qCount += 1
x = randint(10,200)
y = randint(1,x)
print "What is %d %s %d\n" % (x,"-",y)
answer = int(raw_input(""))
if answer == x-y:
scoreCount += 1
print "That is correct!\n"
elif answer != x-y:
print "That is not correct.\n"
elif rand == 3:
qCount += 1
x = randint(1,20)
y = randint(1,20)
print "What is %d %s %d\n" % (x,"*",y)
answer = int(raw_input(""))
if answer == x*y:
scoreCount += 1
print "That is correct!\n"
elif answer != x*y:
print "That is not correct.\n"
raw_input("That's all the questions I have for you. To continue press Enter...")
print "You got %d out of %d questions right." % (scoreCount,qCount)