Advertisement
atulh4c

computer guesses ur number [simple]

Dec 18th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. #Game in which computer guess your number
  2. #coded by atul4c
  3.  
  4. import os
  5. import random
  6. while 1 > 0:
  7.   os.system('cls' if os.name == 'nt' else 'clear')
  8.   print("\nHey in this game you have to guess a number and the computer tries to guess it")
  9.   pguess = int(raw_input("\nGive a number between 1-10000:"))
  10.   cguess = random.randrange(10000) + 1
  11.   print("guess number:" + str(cguess))
  12.   tries = 1
  13.  
  14.   while pguess != cguess:
  15.     cguess = random.randrange(10000) + 1
  16.     os.system('cls' if os.name == 'nt' else 'clear')
  17.     print("\n\n\n\t\tCracking the number:" + str(cguess))
  18.     tries = tries+1
  19.  
  20.   print ("\nThe computer guessed your number in these many attempts:" + str(tries))
  21.   dump = raw_input("")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement