Week 14 Random numbers and binary search

Post date: Feb 2, 2017 3:58:17 PM

import random

print(random.uniform(0,100))

print(random.randint(0,100))

print(random.randint(1,6))

print("I thought of a number.")

number = random.randint(0,100)

counter = 0

while(True):

guess = int(input("Try to guess:"))

counter += 1

if guess == number:

print("What a chance? You nailed it!")

print("It took you", counter, "guesses")

break

elif guess < number:

print("It is less than what I thought of")

else:

print("It is greater than what I thought of")

if counter == 7:

print("You do not have the right strategy!")

print(" +---+ ")

print(" | |")

print(" O |")

print(" /|\ |")

print(" / \ |")

print(" | ")

print("=========")

break