# Author: James Tam # Use this version to use as teaching resource for students # Version: October 24, 2013 (Includes simple debugging messages to show which branches execute) # (Note: although one should never write code this way, I've seen actual examples that are even worse! # The main learning objective is that when you have a series of branches whose execution you are unsure # of: Is the logic correct? Which branch is actually executing then you can quickly see chain of execution # with some output statements. Using these debugging messages doesn't replace the need to understand # code and to conduct hand traces but what they can do is help you pin-point what portions you should be # focusing on. # Also note: this is largely just a sample program meant to illustrate how to use a debugging tool # to trace branches. However there is a logic error that you should be able to spot. import random a = int(input("Enter a number: ")) b = int(input("Enter a number: ")) x = random.randrange(1,1000001) y = random.randrange(1,10000001) z = random.randrange(1,10000001) # JT's note: output messages can be customized to make them more meaningful to the individual if (a > b): print('1') if ((x > 0) and (y > 0)): s1 = "miley" elif (x > 10): s2 = "sheen" elif (y > z): s3 = "twerp" else: s4 = "palin" elif (a < b): if ((x > 0) or (y > 0) or (z > 0)): s5 = "min met" elif ((x > 0) or (y > 0) or (z > 0)): s5 = "max met" else: s6 = "no one could possible need more than 640k RAM"