title: Calculating the percentage to win
body: <p>I am working on a program that will display a random winner depending on their percentage to win. Here's an algorithm that can help you better understand:</p>
  
  <ol>
  <li>Ask multiple users for their names.</li>
  <li>The program should ask if they need more players.</li>
  <li>If they do, then add 3 more players. If not, continue on.</li>
  <li>When done, calculate a random integer between the values of 0 - 100.</li>
  <li>Display to the first player this number, along with the percentage they have to win, then the second, then the third, etc (The closer their number to 100 is a higher percentage)</li>
  <li>Choose a random winner, people with higher percentages should be more likely to win.</li>
  <li>Thank the users for playing the game, and ask if they would like to play again or exit.</li>
  </ol>
  
  <p><strong>How would I determine an appropriate percentage by how close a random number is to 100?</strong></p>
  
  <p>I understand some of this code may be irrelevant, but I wanted my question to make as much sense as possible by understanding the whole program - that helps you more.</p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>#Luck Draw#
  #=========#
  import time
  import random
  
  print("You will be given a number, the closer your number to 100, the higher the chance you win!")
  
  print("Player 1, please input your name.")
  player1 = input()
  
  print("Player 2, please input your name.")
  player2 = input()
  print("Player 3, please input your name.")
  player3 = input()
  
  morePlayers = input("Would you like more players?")
  morePlayers = morePlayers.upper()
  
  if morePlayers == 'YES':
      print("Player 4, please input your name.")
      player4 = input()
      print("Player 5, please input your name.")
      player5 = input()
      print("Player 6, please input your name.")
      player6 = input()
      print("** Unfortunately this program does not support more than six players yet! **")
      time.sleep(2.5)
  
      time.sleep(0.75)
      print("Calculating...")
      time.sleep(3)
      player1num = random.randint(0,100)
      print(player1 + " Your number is:", str(player1num) + "! You have a percantage to win of: ")
      time.sleep(0.75)
      print("Calculating...")
      time.sleep(3)
      player2num = random.randint(0,100)
      print(player2 + " Your number is:", str(player2num) + "! You have a percantage to win of: ")
      time.sleep(0.75)
      print("Calculating...")
      time.sleep(3)
      player3num = random.randint(0,100)
      print(player3 + " Your number is:", str(player3num) + "! You have a percantage to win of: ")
      time.sleep(0.75)
      print("Calculating...")
      time.sleep(3)
      player4num = random.randint(0,100)
      print(player4 + " Your number is:", str(player4num) + "! You have a percantage to win of: ")
      time.sleep(0.75)
      print("Calculating...")
      time.sleep(3)
      player5num = random.randint(0,100)
      print(player5 + " Your number is:", str(player5num) + "! You have a percantage to win of: ")
      time.sleep(0.75)
      print("Calculating...")
      time.sleep(3)
      player6num = random.randint(0,100)
      print(player6 + " Your number is:", str(player6num) + "! You have a percantage to win of: ")
  
      print("And the winner is...")
      time.sleep(1)
      print("...")
      time.sleep(1)
      print(winner + "!")
  else:
      print("Calculating...")
      player1num = random.randint(0,100)
      print(player1 + " Your number is:", str(player1num) + "! You have a percantage to win of: ")
      time.sleep(0.75)
      print("Calculating...")
      time.sleep(3)
      player2num = random.randint(0,100)
      print(player2 + " Your number is:", str(player2num) + "! You have a percantage to win of: ")
      time.sleep(0.75)
      print("Calculating...")
      time.sleep(3)
      player3num = random.randint(0,100)
      print(player3 + " Your number is:", str(player3num) + "! You have a percantage to win of: ")
  </code></pre>