ok I’m confused so there were two questions on the test I just took both that were “What will be printed”
I first got this on
x = 0 if x = 0: print("x is equal to zero.") elif x >= 0: print("x is greater than zero.") else: print("x is less than zero.")
I thought the answer would be that x is equal to zero would be printed. Turns out its a syntax error
then I got this question
x = 5 if x <= 2: print("This is printed") if x <= 4: print("This is also printed") if x <= 6: print("Is this printed?") if x <= 8: print("This might be printed.")
I assumed that because the first one created an error this one would print nothing. However it said it printed two things “Is this printed” and “This might be printed”
x is defined before either one so I figured the first one would print but it said since the first one wasn’t written as x == 0 it wasnt actually set to 0 why is it not the same in both isn’t x set to 0 in the first and x set to 5 in the second before the code blocks?