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
  1. if inputted number is a negative integer then b = b +1
  2. if inputted number is a positive integer then a = a +1
  3. Both A and B
  4. 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.

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.