
Untitled
By: a guest on
Feb 9th, 2012 | syntax:
None | size: 0.48 KB | hits: 717 | expires: Never
import math
user = 0;
result = 50;
num = 1;
print ("Type 'h' for higher and 'l' for lower and 'r' if I'm right");
print ("I'm ready to play!");
while 1 == 1:
print (result);
user = input("Higher (h), Lower (l) or Right (r)?");
if user == "h":
result = math.ceil(result * (50 / num / 100 + 1));
elif user == "l":
result = math.floor(result * (1 - 50 / num / 100));
elif user == "r":
break;
num = num + 1;
print ("Number found in %d tries, not bad!" %(num));