Ask Question
14 May, 12:38

Write a function call it isEvenPositiveInt which takes an integer x and return true if x is positive and also even. Note isinstance (x, int) will return True if x is an integer

So

>>> isinstance (23, int)

True

>>> isinstance (12.34, int)

False

>>> isinstance (12.34, float)

True

+2
Answers (1)
  1. 14 May, 12:58
    0
    The program to this question as follows:

    Program:

    def isEvenPositiveInt (x) : #defining method isEvenPositiveInt

    if x>0: #checking number is positive or not

    if x%2==0: #check true condition

    return True #return value True

    else:

    return False #return value False

    return False #return value False

    print (isEvenPositiveInt (24)) #calling method and print return value

    print (isEvenPositiveInt (-24)) #calling method and print return value

    print (isEvenPositiveInt (23)) #calling method and print return value

    Output:

    True

    False

    False

    Explanation:

    In the above Python program, a method "isEvenPositiveInt" is defined, that accepts a variable "x" as its parameter, inside the method a conditional statement is used, which can be described as follows:

    In the if block the condition "x>0" is passed, that check value is positive, if this condition is true, it will go to another if block. In another, if block is defined, that checks the inserted value is even or not, if the value is even it will return "true", otherwise it will go to the else part, that returns "false".
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a function call it isEvenPositiveInt which takes an integer x and return true if x is positive and also even. Note isinstance (x, ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers