Author Topic: Simple Numbers Mind reading game.  (Read 650 times)

0 Members and 1 Guest are viewing this topic.

Offline josazee

  • /dev/null
  • *
  • Posts: 5
  • Cookies: 0
    • View Profile
Simple Numbers Mind reading game.
« on: September 20, 2014, 11:25:46 pm »
Here's a mind reading game I made in python 2 days ago. You choose a number in your mind and the script tries to predict it.

Code: (python) [Select]

#!/usr/bin/python


import random
print("\nby Eramen.\n\n"
"Choose a Number in your mind from 1-10")


raw_input("\nPress Enter to Continue...")


multNumb = random.randint(1, 9)
addNumb = random.randint(1, 9)
info = "\nMultiply the Number by: "


print info, multNumb


raw_input("\n...")


print("\nDivide the Total by your first number")


raw_input("\n")


info2 = "then add: "
print info2, addNumb


raw_input("\n...")


print("\nAlso add your initial number")


raw_input("\n")


digit = multNumb + addNumb
yourNumb = "\nYour Number should be: "


while True:


   value = raw_input("\nNow, what number do you get: ")


   if not value.isdigit(): continue
   
   print yourNumb, int(value) - digit,'\n'
   
   break

« Last Edit: December 25, 2014, 01:14:58 pm by josazee »

Offline kenjoe41

  • Symphorophiliac Programmer
  • Administrator
  • Baron
  • *
  • Posts: 990
  • Cookies: 224
    • View Profile
Re: Simple Numbers Mind reading game.
« Reply #1 on: September 21, 2014, 12:57:02 am »
First you could use code tags like [ code= python ] . A mod might help you with that if you don't know how to do it.
Then your code is blotted with alot of try-except clauses which aint at all necessary. i mean the whole program doesn't need any exception handling. You just needed to verify the input.

Please get to that cos i won't do it for you if you have any incling to learn.
If you can't explain it to a 6 year old, you don't understand it yourself.
http://upload.alpha.evilzone.org/index.php?page=img&img=GwkGGneGR7Pl222zVGmNTjerkhkYNGtBuiYXkpyNv4ScOAWQu0-Y8[<NgGw/hsq]>EvbQrOrousk[/img]

Offline josazee

  • /dev/null
  • *
  • Posts: 5
  • Cookies: 0
    • View Profile
Re: Simple Numbers Mind reading game.
« Reply #2 on: September 21, 2014, 01:49:53 pm »
Thank you, I do want to learn.

Offline kenjoe41

  • Symphorophiliac Programmer
  • Administrator
  • Baron
  • *
  • Posts: 990
  • Cookies: 224
    • View Profile
Re: Simple Numbers Mind reading game.
« Reply #3 on: September 22, 2014, 01:10:42 pm »
But you haven't removed the silly try....except clauses; yet still you haven't asked how you could do input validation. It disappoints me that you ain't even trying.
Wasted effort kenjoe41, move on.

Sorry i can't remove them for you and slow you development.
If you can't explain it to a 6 year old, you don't understand it yourself.
http://upload.alpha.evilzone.org/index.php?page=img&img=GwkGGneGR7Pl222zVGmNTjerkhkYNGtBuiYXkpyNv4ScOAWQu0-Y8[<NgGw/hsq]>EvbQrOrousk[/img]

Offline josazee

  • /dev/null
  • *
  • Posts: 5
  • Cookies: 0
    • View Profile
Re: Simple Numbers Mind reading game.
« Reply #4 on: December 25, 2014, 01:15:41 pm »
I haven't been online for awhile on evilzone, thanks for the reply and i have modified the code.