Home »
MCQs »
Python MCQs
Consider the following code segment and identify what will be the output of given Python code?
32. Consider the following code segment and identify what will be the output of given Python code?
a = int(input("Enter an integer: "))
b = int(input("Enter an integer: "))
if a <= 0:
b = b +1
else:
a = a + 1
- if inputted number is a negative integer then b = b +1
- if inputted number is a positive integer then a = a +1
- Both A and B
- None of the mentioned above
Answer: C) Both A and B
Explanation:
In above code, if inputted number is a negative integer, then b = b +1 and if inputted number is a positive integer, then a = a +1. Hence, the output will be depending on inputted number.