diff --git a/LeetCode/IF-else-hackerRank/PROBLEM.md b/LeetCode/IF-else-hackerRank/PROBLEM.md new file mode 100644 index 0000000..1d544ab --- /dev/null +++ b/LeetCode/IF-else-hackerRank/PROBLEM.md @@ -0,0 +1,16 @@ +Task +Given an integer, n, perform the following conditional actions: + +TASK +If n is odd, print Weird +If n is even and in the inclusive range of 2 to 5, print Not Weird +If n is even and in the inclusive range of 6 to 20, print Weird +If n is even and greater than 20, print Not Weird +Input Format + +A single line containing a positive integer, n . + + +Output Format + +Print Weird if the number is weird. Otherwise, print Not Weird. \ No newline at end of file diff --git a/LeetCode/IF-else-hackerRank/python/python.py b/LeetCode/IF-else-hackerRank/python/python.py new file mode 100644 index 0000000..e5f6dad --- /dev/null +++ b/LeetCode/IF-else-hackerRank/python/python.py @@ -0,0 +1,20 @@ +#!/bin/python3 + +import math +import os +import random +import re +import sys + +if __name__ == '__main__': + n = int(input().strip()) + if ( (n%2) != 0): + print("Weird") + elif (n in range (2, 5, 2)): + print ("Not Weird") + elif (n in range(6,20,2 )): + print ("Weird") + elif (n > 20): + print ("Not Weird") + else: + print("Weird")