Question:
How to check the status and return True or False using Python?

Summary

Let’s assume that:

Taken two integers variables a and b plus a boolean variable flag. 

Consider two aspects:

  • Either a or b is non-negative then return the flag as false

  • When both a and b are negative then return the flag as true 

  • Or else return a false


Solution

Here is the solution:


#User function Template for python3


# Function to check value and 

# return accordingly

def check_status(a, b, flag):

    ##Your code here

    if a>0 and b<0:

        if flag==False:

            return True

    elif a<0 and b<0 and flag==False:

        return False

    elif a<0 and b>0 and flag==False:

        return True

    elif a<0 and b<0 and flag==True:

        return True

    else:

        return False

    ##Either True or False is returned


Answered by:> >mahesmoojxbu

Credit:> >GeekforGeeks


Suggested blogs:

>How to configure python in jmeter?

>How to mock a constant value in Python?

>Creating a pivot table by 6 month interval rather than year

>How to Install mariaDB client efficiently inside docker?

>Can I call an API to find out the random seed in Python `hash()` function?

>How remove residual lines after merge two regions using Geopandas in python?


Submit
0 Answers