Search This Blog

Using int - Define a function called 'find' which takes three parametersOperations Hacker Rank -Hands - On - Questions and Answers Course ID: 55193

Python - Using Int operations

Define a function called 'find' which takes three parameters. The first parameter is 'num1', the second parameter is 'num2' and the last parameter is 'num3'. The function definition code stub is given in the editor. Print the output of comparison of the numbers in the parameters based on condition given below:

  • In the First print statement check if num1<num2 and num2>=num3
  • In the second print statement check if num1>num2 and num2<=num3
  • In the Third print statement check if num3==num1 and num1!num2
  • Every output must be separated by a single space.
Constraints
  • The output must be of Boolean format.
Input Format Format for Custom Testing
  • In the first line num1 given
  • In the second line num2 given
  • In the second line num3 given
Sample Case 0

Sample Input

STDIN      Function
-----      --------
2       →  num1 = 2
6       →  num2 = 6
4       →  num3 = 4
Sample Output
True False False
Answer:
#!/bin/python3

import math
import os
import random
import re
import sys

#
# Complete the 'find' function below.
#
# The function is expected to return an INTEGER.
# The function accepts following parameters:
#  1. INTEGER num1
#  2. INTEGER num2
#  3. INTEGER num3
#
def find(num1, num2, num3):
    # Write your code here
    print(num1<num2 and num2>=num3, num1>num2 and num2<=num3,
  num3==num1 and num1!=num2)
if __name__ == '__main__':
    num1 = int(input().strip())
    num2 = int(input().strip())
    num3 = int(input().strip())
    find(num1, num2, num3)


Click on Image:


No comments:

Post a Comment

If you have any doubts, Please let us know.