#Programmer Name: Eric Evans
#Program Name: Number Guesser - Take 2
#Program Description: A program that will select a random number and have the user attempt to guess the chosen number.
import random
#Imports the random library to allow for random number generation
runAgain = "Y"
#Declares and initializes the variable runAgain with a value of "Y" 
high = 100
#Declares and initializes the variable high with a value of "100"
low = 1
#Declares and initializes the variable low with a value of "1"
while (runAgain =="Y"):
#Starts a while loop to allow the program to run again.
  computerNumber = random.randint(low, high)
  #Declares and initializes the variable computerNumber with a randomly selected integer between the value of the variables high and low.
  correct = "N"
  #Declares and initializes the variable correct with a value of "N"
  guessCount = 1
  #Declares and initializes the variable guessCount with a value of "1"
  print("Let's play a guessing game")
  #Outputs information to the screen for the user
  print("I am going to pick a whole number between 1 and 100")
  #Outputs information to the screen for the user
  print("After each guess, I will tell you if you are correct or if you're too high or too low.")
  #Outputs information to the screen for the user
  print("Let's get started.")
  #Outputs information to the screen for the user
  print("")
  #Visually breaks-up the information on the screen for the user
  while (correct == "N"):
  #Starts a nested while loop to allow the user to make more guesses until the variable correct is equal to "Y"
    guess = input("What Is Your Guess? ")
    #Declares and initializes variable guess with the value entered by the user from the keyboard
    guess = int(guess)
    #Casts the variable guess as an integer
    if (guess == computerNumber):
    #Starts a conditional if statement to address when the user guesses the correct number
      guessCountAsString = str(guessCount)
      #Declares and initializes variable guessCountAsString with the value of the variable guessCount cast as a string
      print("Wow! You guessed my number in " + guessCountAsString + " guesses!")
      #Outputs information to the screen for the user
      correct = "Y" #Sets the value of the variable correct to "Y" to exit the inner while loop
    elif (guess < computerNumber and (abs(computerNumber - guess) > (int(computerNumber * .15)))):
    #Starts a conditional else/if statement to address when the user guesses a number that is less than the number selected by the computer and is more than 15% of the value of the computerNumber away
      guessAsString = str(guess)
      #Declares and initializes variable guessAsString with the value of the variable guess cast as a string
      print("Your guess of "+ guessAsString + " is too low.")
      #Outputs information to the screen for the user
      print("Please try again.")
      #Outputs information to the screen for the user
      print("")
      #Visually break-up the information on the screen for the user between their guesses
      guessCount = guessCount + 1
      #Increments the value of the guessCount variable by 1
    elif (guess < computerNumber and (abs(computerNumber - guess) <= (int(computerNumber * .15)))):
    #Starts a conditional else/if statement to address when the user guesses a number that is less than the number selected by the computer and is less than or equal to 15% of the value of the computerNumber away
      guessAsString = str(guess)
      #Declares and initializes variable guessAsString with the value of the variable guess cast as a string
      print("Your guess of "+ guessAsString + " is too low.")
      #Outputs information to the screen for the user
      print("You are very close!!!")
      #Outputs information to the screen for the user
      print("Please try again.")
      #Outputs information to the screen for the user
      print("")
      #Visually break-up the information on the screen for the user between their guesses
      guessCount = guessCount + 1
      #Increments the value of the guessCount variable by 1
    elif (guess > computerNumber and (abs(computerNumber - guess) > (int(computerNumber * .15)))):
    #Starts a conditional else/if statement to address when the user guesses a number that is greater than the number selected by the computer and is more than 15% of the value of the computerNumber away
      guessAsString = str(guess)
      #Declares and initializes variable guessAsString with the value of the variable guess cast as a string
      print("Your guess of "+ guessAsString + " is too high.")
      #Outputs information to the screen for the user
      print("Please try again.")
      #Outputs information to the screen for the user
      print("")
      #Visually break-up the information on the screen for the user between their guesses
      guessCount = guessCount + 1
      #Increments the value of the guessCount variable by 1
    elif (guess > computerNumber and (abs(computerNumber - guess) <= (int(computerNumber * .15)))):
    #Starts a conditional else/if statement to address when the user guesses a number that is greater than the number selected by the computer and is less than or equal to 15% of the value of the computerNumber away
      guessAsString = str(guess)
      #Declares and initializes variable guessAsString with the value of the variable guess cast as a string
      print("Your guess of "+ guessAsString + " is too high.")
      #Outputs information to the screen for the user
      print("You are very close!!!")
      #Outputs information to the screen for the user
      print("Please try again.")
      #Outputs information to the screen for the user
      print("")
      #Visually break-up the information on the screen for the user between their guesses
      guessCount = guessCount + 1
      #Increments the value of the guessCount variable by 1
  print("Would You Like to Run the Program Again?")
  #Outputs information to the screen for the user
  runAgain = input("[Y]es or [N]o")
  #Sets the value of the variable runAgain to the keyboard input received to allow user to repeat program or exit the outer-loop
  runAgain = runAgain.upper()
  #Sets the value of the variable runAgain to upper-case
print("Thank you for playing.")
#Outputs information to the screen for the user
print("Exiting Program - Goodbye")
#Outputs information to the screen for the user
Python 3.6.1 (default, Dec 2015, 13:05:11) [GCC 4.8.2] on linux