Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PyGuessTheNum2
#python 3.6.9 #PyGuessTheNum2: the number guessing game and example of enumeration and is operator #this code is created by Rezaul Hoque on May 03,2022; #contact:jewelmrh@yahoo.com;Dhaka,Bangladesh;https://rezaulhoque.wordpress.com,https://hoquestake.blogspot.com #note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; from enum import Enum import random def Deco(fun): def wrap(*args,**kwargs): print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>") fun(*args,**kwargs) print("May 03,2022") print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>") return wrap @Deco #@Deco is same as theFun= Deco(theFun) def theFun(s1,s2): print(f"{s1} {s2}") class Status(Enum): Awesome=1 WellDone=2 Good=3 NiceTry= 4 HecticTry= 5 class Guess: def start(self): num= random.randint(1,15) countNum=0 for countNum in range(0,5): print('Guess a number between 1 and 15:\n') guess= int(input("Guess:\n")) countNum += 1 if guess<num: print("Your guess is too low") elif guess>num: print("Your guess is too high") else: break if guess==num: print (f"Congrats! You guess the number in {countNum} tries.") if Status(countNum) is Status.Awesome: print("That is awesome! ") if Status(countNum) is Status.Weldone: print("Bravo! ") if Status(countNum) is Status.Good: print("Good job! ") if Status(countNum) is Status.NiceTry: print("Nice try! ") if Status(countNum) is Status.HecticTry: print("What an hectic effort! ") else: print (f"Sorry! You failed to guess the number. It is {num}") theFun("\'Guess The Number\'","Game") a=Guess() a.start()
run
|
edit
|
history
|
help
0
PYTHON 3
Email Validation
linked_lists_2+decisions
My Intro
sensi
binary_search
PyMetaParam
delta5
Linked Lists in python
Reverse function