Computer Science
Consider the following code segment:
a = int(input("Enter an integer: "))
b = int(input("Enter an integer: "))
if a <= 0:
b = b +1
else:
a = a + 1
if a > 0 and b > 0:
print ("W")
elif a > 0:
print("X")
if b > 0:
print("Y")
else:
print("Z")
What letters will be printed if the user enters 0 for a and 0 for b ?
- Only W
- Only X
- Only Y
- W and X
- W, X and Y
Python Control Flow
12 Likes
Answer
Only Y
Answered By
5 Likes
Related Questions
What does the following Python program display ?
x = 3 if x == 0: print ("Am I here?", end = ' ') elif x == 3: print("Or here?", end = ' ') else : pass print ("Or over here?")If the user inputs : 2<ENTER>, what does the following code snippet print?
x = float(input()) if(x==1): print("Yes") elif (x >= 2): print("Maybe") else: print ("No")Consider the following code segment:
a = int(input("Enter an integer: ")) b = int(input("Enter an integer: ")) if a <= 0: b = b +1 else: a = a + 1 if a > 0 and b > 0: print ("W") elif a > 0: print("X") if b > 0: print("Y") else: print("Z")What letters will be printed if the user enters 1 for a and 1 for b ?
Consider the following code segment:
a = int(input("Enter an integer: ")) b = int(input("Enter an integer: ")) if a <= 0: b = b +1 else: a = a + 1 if a > 0 and b > 0: print ("W") elif a > 0: print("X") if b > 0: print("Y") else: print("Z")What letters will be printed if the user enters 1 for a and -1 for b?