My name is Tyson, I have been programming with python just a little over 1 month now. I found the forums and just thought it was a great place to get help and help anyone who needs it with python.
This is an example of some of the stuff i do now:
print('Random Sum Generator')
sort = raw_input('What sorts of sums would you like to generate: ')
mode = raw_input('What mode would you like to generate sums with: ')
while sort == '+' and mode == 'easy':
print('')
print('Here is your sum: ')
no1 = random.randrange(1, 30)
no2 = random.randrange(1, 30)
print(`no1` +' + '+ `no2`)
answer = input('Answer: ')
if answer == no1 + no2:
print('Well done!')
elif answer != no1 + no2:
print('Sorry that was wrong.')
while sort == '-' and mode == 'easy':
print('')
print('Here is your sum: ')
no1 = random.randrange(1, 30)
no2 = random.randrange(1, 30)
print(`no1` +' - '+ `no2`)
answer = input('Answer: ')
if answer == no1 - no2:
print('Well done!')
elif answer != no1 - no2:
print('Sorry that was wrong.')
while sort == '+' and mode == 'medium':
print('')
print('Here is your sum: ')
no1 = random.randrange(1, 40)
no2 = random.randrange(1, 40)
print(`no1` +' + '+ `no2`)
answer = input('Answer: ')
if answer == no1 + no2:
print('Well done!')
elif answer != no1 + no2:
print('Sorry that was wrong.')
while sort == '-' and mode == 'medium':
print('')
print('Here is your sum: ')
no1 = random.randrange(1, 40)
no2 = random.randrange(1, 40)
print(`no1` +' - '+ `no2`)
answer = input('Answer: ')
if answer == no1 - no2:
print('Well done!')
elif answer != no1 - no2:
print('Sorry that was wrong.')
while sort == '+' and mode == 'hard':
print('')
print('Here is your sum: ')
no1 = random.randrange(1, 50)
no2 = random.randrange(1, 50)
print(`no1` +' + '+ `no2`)
answer = input('Answer: ')
if answer == no1 + no2:
print('Well done!')
elif answer != no1 + no2:
print('Sorry that was wrong.')
while sort == '-' and mode == 'hard':
print('')
print('Here is your sum: ')
no1 = random.randrange(1, 50)
no2 = random.randrange(1, 50)
print(`no1` +' - '+ `no2`)
answer = input('Answer: ')
if answer == no1 - no2:
print('Well done!')
elif answer != no1 - no2:
print('Sorry that was wrong.')
I know its quite long but what it is, is a random sum generator. It will prompt you with two questions; What sort of sum and What sort of mode. It will now give you unlimited about of random sums.
Thanks,
Tyson.S


Sign In
Create Account

Back to top











