Thursday, December 19, 2013

XOR

def XOR():
  # get inputs and echo them to user (don't change these 6 lines)
  A = input ("Please enter 1 or 0 for A: ")
  B = input ("Please enter 1 or 0 for B: ")
  print "A is:  "
  print A
  print "B is:  "
  print B
 
  #set up blank picture (don't change this)
  result = makeEmptyPicture (100, 100)
 
  # conditional (if) statement(s) to check whether sA XOR B is true or false
  # and dispay a red FALSE or green TRUE in a blank picture
  # HINT 1: You should have 4 lines of code here; we want you to use 2 separate
  # statements this time. Use the "addText" function also.
  # HINT 2: "addText(result, 20, 20, "TRUE", green)" is a handy statement!

 
  if A != B:
    addText(result, 25, 50, "True", green)
  if A == B:
    addText(result, 25, 50, "False", red)
 
  # display results (don't change this)
  repaint (result)

No comments:

Post a Comment