import serial, sys, random
if sys. platform. fild("win")!=-1:
port=0
elif sys. platform. fild("linux")!=-1:
port="/dev/ rfcomm0"
elif sys. platform. find("darwin")!=-1:
port="/dev/ tty. pybook"
num=random. randint(1, 10)
serial=serial. Serial(port)
print "Waiting for massage…"
while True:
msg=serial. readline().strip()
guess=int(msg)
print "Guess: %d" %guess
if guess>num:
print>>serial, "My nymber is smaller"
elif guess<num:
print>>serial, "My nymber is larger"
else:
print>>serial, "Correct! bye!"
break