• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# guess_it

a guest Dec 12th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import random ,re
2. import time ,sys
3. from datetime import datetime
4. import subprocess as sp
5. sub= sp.call('clear',shell=True)
6.
7. CEND = '\33[0m'
8. CRED = '\33[31m'
9. CBLUE = '\33[34m'
10. CWHITE = '\33[37m'
11. CGREY = '\33[90m'
12. CBEIGE = '\33[36m'
13. CVIOLET = '\33[35m'
14. CBLUEBG = '\33[44m'
15. CYELLOW = '\33[33m'
16. CGREYBG = '\33[100m'
17. CWHITE2 = '\33[97m'
18. CREDBG2 = '\33[101m'
19. CGREEN2 = '\33[92m'
20. CYELLOWBG = '\33[43m'
21. CUNDERLINE = '\33[4m'
22. CVIOLETBG2 = '\33[105m'
23. CYELLOWBG2 = '\33[103m'
24.
25. def title():
26.     print ("   "+CREDBG2+"TRY YOUR LUCK ON NUMBER GUESSING"+CEND)
27.     print ("         "+CGREYBG+"   ᴺᵘᵐᵇᵉʳˢ ᶠʳᵒᵐ ¹⁻⁹"+CEND)
28.     print ("")
29. title()
30. def logs():
31.     date = datetime.now()
32.     print(CVIOLETBG2+"{0}:{1}:{2} ".format(date.hour,date.minute,date.second)+CEND+"           "+CYELLOWBG2+"YOU HAVE"+CEND+CREDBG2+" 0 "+CEND+'\x1b[7;35;40m' +"point"+'\x1b[0m')
33.     print(CVIOLETBG2+"{0}/{1}/{2}".format(date.day,date.month,date.year)+CEND)
34.     print("")
35.     print("")
36. logs()
37.
38. date = datetime.now()
39. win = False
40. won = 0
41. def main():
42.      global retries,guess,rand_num,win,won
43.      global date
44.      rand_num = 1
45.      guess = 0
46.      retries = 10
47.      won = won
48.      win = False
49.      while retries > 0 and win == False:
50.           choose = input(CBLUEBG+"         Guess a number:" +CEND+ " ").replace(" ","")
51.           guess = choose[:2]
52.           remainder = choose[2:]
53.           if guess.isalpha():
55.               main()
56.           elif re.findall("[a-zA-Z]",guess):
58.               main()
59.           elif not guess:
60.               print (CRED+"You Guessed Nothing"+CEND)
61.               main()
62.           elif re.findall("\.",guess) and re.findall("[0-9]",guess):
63.               print (CRED+"Whole Numbers Only, Please!"+CEND)
64.               main()
65.           elif re.findall("[^0-9a-zA-Z]+",guess):
66.               print (CRED+"Just Numbers Only , Please!"+CEND)
67.               main()
68.           elif guess.isdigit() and int(guess) <1:
69.               print (CRED+"Choose Numbers From 1 - 9!"+CEND)
70.               main()
71.           elif int(guess) >9:
72.               #this if statement isn't needed in this case except 1-90
73.               if len(choose) >100000:
74.                   print (CRED+"Last {} Digit(s) is Removed".format(len(remainder))+CEND)
75.                   print(CRED+"Choose Numbers From 1 - 9!"+CEND)
76.                   main()
77.               else:
78.                   print(CRED+"Choose Numbers From 1 - 9!"+CEND)
79.                   main()
80.           else :
81.               if len(choose) >2:
82.                   print (CRED+"Last {} Digit(s) is Removed".format(len(remainder))+CEND)
83.                   rand_num = random.randint(1,9)
84.                   compare()
85.               else:
86.                   rand_num = random.randint(1,9)
87.                   compare()
88.      if win == True:
89.          print("")
90.          pass
91.      else:
92.          import androidhelper
93.          droid = androidhelper.Android()
94.          droid.mediaPlay("/storage/emulated/0/qpython/sounds/nolive.ogg")
95.          print("       "+CRED+CUNDERLINE+"You Are Out Of Lives!!"+CEND+"😢😢"+CEND)
96.          print ("")
97.          time.sleep(1)
98. def compare():
99.      import androidhelper
100.      droid = androidhelper.Android()
101.      global retries,win
102.      near = int(guess) - rand_num
103.      if int(guess) == rand_num:
104.           print('\x1b[7;35;40m' + "WELLDONE ,You guessed correctly!!!  "+ '\x1b[0m')
105.           print (CWHITE+'         ✨✨✨✨('+str(rand_num)+')✨✨✨✨'+CEND)
106.           win = True
107.      elif int(guess) > rand_num and near !=-2 and near !=2 and near !=1 and near !=-1:
108.           droid.mediaPlay("/storage/emulated/0/qpython/sounds/wrong.ogg")
109.           print (CVIOLET+"Your Guess is higher!"+CEND)
110.           print (CYELLOW+'The winning number is'+CEND +'{:>24}'.format(CGREY+'👉<'+str(rand_num)+'>'+CEND))
111.           print("")
112.           retries = retries - 1
113.      elif near == 2 or near == -2:
114.          droid.mediaPlay("/storage/emulated/0/qpython/sounds/wrong.ogg")
115.          print(CWHITE2+"That Was So Close!"+CEND)
116.          print(CYELLOW+'The winning number is'+CEND +'{:>24}'.format(CGREY+'👉<'+str(rand_num)+'>'+CEND))
117.          print("")
118.      elif near ==1 or near ==-1:
119.          droid.mediaPlay("/storage/emulated/0/qpython/sounds/wrong.ogg")
120.          print(CWHITE+"You Almost Hit It!!!"+CEND)
121.          print(CYELLOW+'The winning number is'+CEND +'{:>24}'.format(CGREY+'👉<'+str(rand_num)+'>'+CEND))
122.          print("")
123.      else:
124.           droid.mediaPlay("/storage/emulated/0/qpython/sounds/wrong.ogg")
125.           print (CVIOLET+"Your Guess is lower!"+CEND)
126.           print (CYELLOW+'The winning number is'+CEND +'{:>24}'.format(CGREY+'👉<'+str(rand_num)+'>'+CEND))
127.           print ("")
128.           retries = retries - 1
129. def repeat():
130.      import subprocess as sp
131.      import androidhelper
132.      droid = androidhelper.Android()
133.      global win,won,date
134.      date = datetime.now()
135.      if win == True:
136.          won = won +1
137.          droid.mediaPlay("/storage/emulated/0/qpython/sounds/clapping.ogg")
138.
139.      else :
140.          won = won
141.          pass
142.      time.sleep(2)
143.      re_play = input(CBLUEBG+"would you like to play again?[Y/N]: "+CEND)
144.      if re_play == "Y" or re_play == "y":
145.        droid.mediaPlay("/storage/emulated/0/qpython/sounds/newgame.ogg")
146.        sub= sp.call('clear',shell=True)
147.        title()
148.        if win == True:
149.
150.          print(CVIOLETBG2+"{0}:{1}:{2} ".format(date.hour,date.minute,date.second)+CEND+"   "+CYELLOWBG2+"YOU HAVE"+CEND+CREDBG2+" {} ".format(won)+CEND+'\x1b[7;35;40m' +"point So Far"+'\x1b[0m')
151.          print(CVIOLETBG2+"{0}/{1}/{2}".format(date.day,date.month,date.year)+CEND)
152.          print ("")
153.          print ("")
154.          time.sleep(2)
155.          main()
156.        else :
157.          won = won
158.          print(CVIOLETBG2+"{0}:{1}:{2} ".format(date.hour,date.minute,date.second)+CEND+"   "+CYELLOWBG2+"YOU HAVE"+CEND+CREDBG2+" {} ".format(won)+CEND+'\x1b[7;35;40m' +"point So Far"+'\x1b[0m')
159.          print(CVIOLETBG2+"{0}/{1}/{2}".format(date.day,date.month,date.year)+CEND)
160.          print ("")
161.          print ("")
162.          time.sleep(2)
163.          main()
164.      elif re_play == "N" or re_play == "n":
165.           print ("")
166.           print (CYELLOWBG2+"GOODBYE , I hope you enjoyed!"+CEND)
167.           time.sleep(2)
168.           sys.exit()
169.      else:
170.           print(CRED+"please enter Y or N"+CEND)
171.           win = False
172.           repeat()
173.
174. main()
175. repeat()
176. repeat()
177. repeat()
178. print("")
179. print(CRED+ "APPLICATION CLOSED BY FORCE!!" +CEND)
180. sys.exit()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?