Cooperative Learning Question

On a piece of paper write your NAME and DATE and SECTION.

  1. What is the output of this code if x were 5?
    	if x > 5:
    		print("red",end="")
    	if x == 7:
    		print("blue",end="")
    	if x <= 10:
    		print("white",end="")
    	else:
    		print("green",end="")
            print("yellow")
    	
    

    ANSWER: whiteyellow
  2. For any value of x, is it possible to get the output "redbluewhitegreenyellow" from this code? If so, what value for x would cause it? If not, why not?
    ANSWER: no, it is not possible. Because the white and green are printed in an if/else, only one of the two will be output
  3. For any value of x, is it possible to get the output "redwhiteyellow" from this code? If so, what value for x would cause it? If not, why not?
    ANSWER: yes, x greater than 5 and <= 10, but not 7, so 6, 8, 9, 10 (assuming integers)

Spend a minute talking to your neighbor about the question. Convince them your answer is right if you can!

Turn the paper in for attendance.