Python Forum
My first go at Python hasn't gone well
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My first go at Python hasn't gone well
#5
Thanks folks. I can see why it wouldn't like that. I hadn't realised it treated every input as a string but now it makes sense. I've also taken the advice on how to combine the other bits and it's looking much tidier now.

print('Let us practice our seven times tables')
table = 7
from random import randint
number = randint(2, 12)
correct = number * table
response = input('What\'s ' + str(number) + ' X ' + str(table) + ' = ')
if int(response) == correct:
   print('Well done. You\'re spot on.')
else:
   print('Actually it is')
   print(correct)
Next step will be to get to grips with how to make it repeat and possibly add a scoring element and the ability to change the times table you're practicing.

Many thanks for the help.
Reply


Messages In This Thread
RE: My first go at Python hasn't gone well - by whythedevilnot - Dec-02-2016, 09:55 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020