The game is challenge you how to find a random number thats you able for set the range, when you try to guess it and you get the number is higher, you will get the result "Your number too hight" or otherwise your predicted number is lower, the result is "Your number too small".
Other feature is you can set how many tries that you allowed to do, when you reach the limit, you will get "How stupid you are.." as a result.
And while you get the right number you will know how many tries you did, and the program will ask to continue playing, reset the game, or close the game.
Now the syntax:
#!/usr/bin/python
import random
z=3
while z<5:
print "|||------------------------------------|||"
print " || Welcome!! ||"
print " |------------------------------------|"
print "Guess the number game STARTED"
nama=raw_input("Enter your nickname: ")
A=input("Your min number on range: ")
B=input("Your max number on range: ")
maks=input("Your max tries: ")
print "The number which predicted by",nama,"have range between",A,"and",B
print "Your max tries are",maks,"tries"
print " ---------"
print "< GOOD LUCK >"
print " ---------"
while True:
C=random.randint(A,B)
x=0
print "--------------------------------------------------"
print "Your random number selected!!"
while True:
angka=input("Guess the number is? ")
x+=1
if x>maks:
print "How stupid you are.."
break
if angka==C:
print "Congratulations!!",nama," right, on",x,"tries"
print "The number is ",angka
break
elif angka<C:
print "Your number too small"
elif angka>C:
print "Your number too big"
lagi=''
while lagi!='y' and lagi!='Y' and lagi!='t' and lagi!='T' and lagi!='n' and lagi!='N':
lagi=raw_input('(y) to play again, (t) to reset the game, (n) to quit : ')
if lagi in ['t','T']:
break
if lagi in ['n','N']:
z=10
break
This all i can give to you, if you get aa error problem, just wirte it on comment and i will answer it.
Thanks for visiting..
NIce post ^^
ReplyDeletethanks :D
Delete