@Nathan2196/

NumberGuesser

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from random import randint
import time
import math

number = 0
guess = 0
difficulty = (int(input("Select Difficulty: 1, 2, 3, 4, 5 ")))
if(difficulty ==1):
	number2 = randint(70, 100)
elif(difficulty ==2):
	number2 = randint(200, 700)
elif(difficulty ==3):
	number2 = randint(900, 2000) 
elif(difficulty ==4):
	number2 = randint(5000, 10000)
elif(difficulty ==5):
	number2 = randint(10000, 100000)
else:
	print("Unrecognized")

number1 = 1

number = randint(number1, number2)
x = int(math.log(number2 - number1 + 1)/math.log(2)+1)
print("You have ", x, " guesses total")
while(1==1):
  if(x>0):
    print("Guess a number from, ", number1, " to, ", number2)
    guess = (int(input("Enter your guess here : ")))
    if(guess < number):
      print("")
      print(guess, " is too low!, try again...")
    elif(guess > number):
      print("")
      print(guess, " is too high!, try again...")
    if(guess == number):
      print("~~~~~~~~~~~~~~")
      print(number, " is correct!") 
      print("~~~~~~~~~~~~~~")  
      break
    x = x - 1
    print("You have ", x, " guesses left") 
    print("")
  elif(x == 0):
    print("~~~~~~~~~~~~~")
    print("You have run out of guesses...")
    print("Your number was...", number)
    print("~~~~~~~~~~~~~")
    break