chevron_left chevron_right

• 0 Vote(s) - 0 Average

 [Python Game]Guess The Number filter_list Linear Mode Threaded Mode View a Printable Version Author Message
RE: [Python Game]Guess The Number #11
It's a nice work, the code is well written and indentation is good, keep practicing
Everything is relative

RE: [Python Game]Guess The Number #12
It's a nice work, the code is well written and indentation is good, keep practicing
Everything is relative

RE: [Python Game]Guess The Number #13
xD haha funny game thanks mate , cooling coding

RE: [Python Game]Guess The Number #14
Nice work! I would've done something like this:
Code:
import random

print '''
_____ _     _____ ____  ____    _____  _     _____
/  __// \ /\/  __// ___\/ ___\  /__ __\/ \ /|/  __/
| |  _| | |||  \  |    \|    \    / \  | |_|||  \
| |_//| \_/||  /_ \___ |\___ |    | |  | | |||  /_
\____\\____/\____\\____/\____/    \_/  \_/ \|\____\

_      _     _      ____  _____ ____
/ \  /|/ \ /\/ \__/|/  _ \/  __//  __\
| |\ ||| | ||| |\/||| | //|  \  |  \/|
| | \||| \_/|| |  ||| |_\\|  /_ |    /
\_/  \|\____/\_/  \|\____/\____\\_/\_\

By Psycho_Coder @HackCommunity

The game is simple a random number is chosen by this program everytime and you have to guess it right
If the number is less than what you guessed it will say "Too high guess" else "Too low" and if your
guess is correct then you are the winner.The number will be between 1 and 100 and you will get 5 chances
to guess it correctly
'''

def getRandomNum():
return random.randint(1, 100)

def game():
count=0
MAX_NO_OF_GUESS=5
num=getRandomNum()
while count<MAX_NO_OF_GUESS:
count +=1
print " Enter Your Guess :"
guess=int(input())
if guess < num:
print "You guessed the number too low"
elif guess > num:
print "You guessed the number too High"
else:
print "Congratulations! You guessed the number correctly."
print "You Guessed the number correctly in ",str(count)," steps"
return
print "Aww! You Ran out of your chances."
print "The Correct answer would have been :",str(num)

game()

Why do you store title in a variable, then have a function write out a description? You don't loop the game, so the title is only used once, why store it in a variable? Perhaps add a high score system or allow the user the option to play again would be my suggestions.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

RE: [Python Game]Guess The Number #15
Nice work! I would've done something like this:
Code:
import random

print '''
_____ _     _____ ____  ____    _____  _     _____
/  __// \ /\/  __// ___\/ ___\  /__ __\/ \ /|/  __/
| |  _| | |||  \  |    \|    \    / \  | |_|||  \
| |_//| \_/||  /_ \___ |\___ |    | |  | | |||  /_
\____\\____/\____\\____/\____/    \_/  \_/ \|\____\

_      _     _      ____  _____ ____
/ \  /|/ \ /\/ \__/|/  _ \/  __//  __\
| |\ ||| | ||| |\/||| | //|  \  |  \/|
| | \||| \_/|| |  ||| |_\\|  /_ |    /
\_/  \|\____/\_/  \|\____/\____\\_/\_\

By Psycho_Coder @HackCommunity

The game is simple a random number is chosen by this program everytime and you have to guess it right
If the number is less than what you guessed it will say "Too high guess" else "Too low" and if your
guess is correct then you are the winner.The number will be between 1 and 100 and you will get 5 chances
to guess it correctly
'''

def getRandomNum():
return random.randint(1, 100)

def game():
count=0
MAX_NO_OF_GUESS=5
num=getRandomNum()
while count<MAX_NO_OF_GUESS:
count +=1
print " Enter Your Guess :"
guess=int(input())
if guess < num:
print "You guessed the number too low"
elif guess > num:
print "You guessed the number too High"
else:
print "Congratulations! You guessed the number correctly."
print "You Guessed the number correctly in ",str(count)," steps"
return
print "Aww! You Ran out of your chances."
print "The Correct answer would have been :",str(num)

game()

Why do you store title in a variable, then have a function write out a description? You don't loop the game, so the title is only used once, why store it in a variable? Perhaps add a high score system or allow the user the option to play again would be my suggestions.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Users browsing this thread: 1 Guest(s)