Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random ,re
- import time ,sys
- from datetime import datetime
- import subprocess as sp
- sub= sp.call('clear',shell=True)
- CEND = '\33[0m'
- CRED = '\33[31m'
- CBLUE = '\33[34m'
- CWHITE = '\33[37m'
- CGREY = '\33[90m'
- CBEIGE = '\33[36m'
- CVIOLET = '\33[35m'
- CBLUEBG = '\33[44m'
- CYELLOW = '\33[33m'
- CGREYBG = '\33[100m'
- CWHITE2 = '\33[97m'
- CREDBG2 = '\33[101m'
- CGREEN2 = '\33[92m'
- CYELLOWBG = '\33[43m'
- CUNDERLINE = '\33[4m'
- CVIOLETBG2 = '\33[105m'
- CYELLOWBG2 = '\33[103m'
- def title():
- print (" "+CREDBG2+"TRY YOUR LUCK ON NUMBER GUESSING"+CEND)
- print (" "+CGREYBG+" ᴺᵘᵐᵇᵉʳˢ ᶠʳᵒᵐ ¹⁻⁹"+CEND)
- print ("")
- title()
- def logs():
- date = datetime.now()
- 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')
- print(CVIOLETBG2+"{0}/{1}/{2}".format(date.day,date.month,date.year)+CEND)
- print("")
- print("")
- logs()
- date = datetime.now()
- win = False
- won = 0
- def main():
- global retries,guess,rand_num,win,won
- global date
- rand_num = 1
- guess = 0
- retries = 10
- won = won
- win = False
- while retries > 0 and win == False:
- choose = input(CBLUEBG+" Guess a number:" +CEND+ " ").replace(" ","")
- guess = choose[:2]
- remainder = choose[2:]
- if guess.isalpha():
- print(CRED+"Numbers Only, Please!"+CEND)
- main()
- elif re.findall("[a-zA-Z]",guess):
- print(CRED+"Non-Alphabet Numbers, Please!"+CEND)
- main()
- elif not guess:
- print (CRED+"You Guessed Nothing"+CEND)
- main()
- elif re.findall("\.",guess) and re.findall("[0-9]",guess):
- print (CRED+"Whole Numbers Only, Please!"+CEND)
- main()
- elif re.findall("[^0-9a-zA-Z]+",guess):
- print (CRED+"Just Numbers Only , Please!"+CEND)
- main()
- elif guess.isdigit() and int(guess) <1:
- print (CRED+"Choose Numbers From 1 - 9!"+CEND)
- main()
- elif int(guess) >9:
- #this if statement isn't needed in this case except 1-90
- if len(choose) >100000:
- print (CRED+"Last {} Digit(s) is Removed".format(len(remainder))+CEND)
- print(CRED+"Choose Numbers From 1 - 9!"+CEND)
- main()
- else:
- print(CRED+"Choose Numbers From 1 - 9!"+CEND)
- main()
- else :
- if len(choose) >2:
- print (CRED+"Last {} Digit(s) is Removed".format(len(remainder))+CEND)
- rand_num = random.randint(1,9)
- compare()
- else:
- rand_num = random.randint(1,9)
- compare()
- if win == True:
- print("")
- pass
- else:
- import androidhelper
- droid = androidhelper.Android()
- droid.mediaPlay("/storage/emulated/0/qpython/sounds/nolive.ogg")
- print(" "+CRED+CUNDERLINE+"You Are Out Of Lives!!"+CEND+"😢😢"+CEND)
- print ("")
- time.sleep(1)
- def compare():
- import androidhelper
- droid = androidhelper.Android()
- global retries,win
- near = int(guess) - rand_num
- if int(guess) == rand_num:
- print('\x1b[7;35;40m' + "WELLDONE ,You guessed correctly!!! "+ '\x1b[0m')
- print (CWHITE+' ✨✨✨✨('+str(rand_num)+')✨✨✨✨'+CEND)
- win = True
- elif int(guess) > rand_num and near !=-2 and near !=2 and near !=1 and near !=-1:
- droid.mediaPlay("/storage/emulated/0/qpython/sounds/wrong.ogg")
- print (CVIOLET+"Your Guess is higher!"+CEND)
- print (CYELLOW+'The winning number is'+CEND +'{:>24}'.format(CGREY+'👉<'+str(rand_num)+'>'+CEND))
- print("")
- retries = retries - 1
- elif near == 2 or near == -2:
- droid.mediaPlay("/storage/emulated/0/qpython/sounds/wrong.ogg")
- print(CWHITE2+"That Was So Close!"+CEND)
- print(CYELLOW+'The winning number is'+CEND +'{:>24}'.format(CGREY+'👉<'+str(rand_num)+'>'+CEND))
- print("")
- elif near ==1 or near ==-1:
- droid.mediaPlay("/storage/emulated/0/qpython/sounds/wrong.ogg")
- print(CWHITE+"You Almost Hit It!!!"+CEND)
- print(CYELLOW+'The winning number is'+CEND +'{:>24}'.format(CGREY+'👉<'+str(rand_num)+'>'+CEND))
- print("")
- else:
- droid.mediaPlay("/storage/emulated/0/qpython/sounds/wrong.ogg")
- print (CVIOLET+"Your Guess is lower!"+CEND)
- print (CYELLOW+'The winning number is'+CEND +'{:>24}'.format(CGREY+'👉<'+str(rand_num)+'>'+CEND))
- print ("")
- retries = retries - 1
- def repeat():
- import subprocess as sp
- import androidhelper
- droid = androidhelper.Android()
- global win,won,date
- date = datetime.now()
- if win == True:
- won = won +1
- droid.mediaPlay("/storage/emulated/0/qpython/sounds/clapping.ogg")
- else :
- won = won
- pass
- time.sleep(2)
- re_play = input(CBLUEBG+"would you like to play again?[Y/N]: "+CEND)
- if re_play == "Y" or re_play == "y":
- droid.mediaPlay("/storage/emulated/0/qpython/sounds/newgame.ogg")
- sub= sp.call('clear',shell=True)
- title()
- if win == True:
- 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')
- print(CVIOLETBG2+"{0}/{1}/{2}".format(date.day,date.month,date.year)+CEND)
- print ("")
- print ("")
- time.sleep(2)
- main()
- else :
- won = won
- 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')
- print(CVIOLETBG2+"{0}/{1}/{2}".format(date.day,date.month,date.year)+CEND)
- print ("")
- print ("")
- time.sleep(2)
- main()
- elif re_play == "N" or re_play == "n":
- print ("")
- print (CYELLOWBG2+"GOODBYE , I hope you enjoyed!"+CEND)
- time.sleep(2)
- sys.exit()
- else:
- print(CRED+"please enter Y or N"+CEND)
- win = False
- repeat()
- main()
- repeat()
- repeat()
- repeat()
- print("")
- print(CRED+ "APPLICATION CLOSED BY FORCE!!" +CEND)
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement