#!/usr/bin/env python3.1
#This is a guess the number game.
import random;
guessesToken = 0;
print("Hello! What is your name?");
myName = input();
number = random.randint(1, 20);
print("Well, Myfriend "+myName+" let's play a game");
print("Guess a number between 1 and 20");
while guessesToken < 6:
guess = input();
guess = int(guess);
guessesToken = guessesToken + 1;
if guess < number:
print("Your guess is too low!");
if guess > number:
print("Your guess is too high!");
if guess == number:
break;
if guess == number:
guessesToken = str(guessesToken);
print("You guessed it within "+guessesToken+" times congratulations!");
if guess != number:
print("You failed man!");
C++, Java, Python, PHP, Programming Tips, Linux, Bash Shell Scripting, Security And Tech Stuff
Showing posts with label guess. Show all posts
Showing posts with label guess. Show all posts
Saturday, January 29, 2011
Guess The Number Simple Game in Python
I am learning python at this moment and created simple game. I saw some tutorial before and just coded this.
Subscribe to:
Posts (Atom)