Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Python If-Else Hacker Rank Solution – Queslers

Problem: Python If-Else Hacker Rank Solution

Task

Given an integer, , perform the following conditional actions:

  • If  is odd, print Weird
  • If  is even and in the inclusive range of  to , print Not Weird
  • If  is even and in the inclusive range of  to , print Weird
  • If  is even and greater than , print Not Weird

Input FormatA single line containing a positive integer, .Constraints

Output FormatPrint Weird if the number is weird; otherwise, print Not Weird.Sample Input 0

3

Sample Output 0

Weird

Sample Input 1

24

Sample Output 1

Not Weird

ExplanationSample Case 0:
 is odd and odd numbers are weird, so we print Weird.Sample Case 1:
 and  is even, so it isn’t weird. Thus, we print Not Weird.

Python If-Else Hacker Rank Solution

if __name__ == '__main__':
    n = int(input().strip())
    
    if n%2!=0:
       print("Weird")

    else:
        if n>=2 and n<=5:
            print("Not Weird")
        elif n>=6 and n<=20:
            print("Weird")
        elif n>20:
            print("Not Weird")
Python If-Else Hacker Rank Solution Review:

In our experience, we suggest you solve this Python If-Else Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

Python If-Else problem is available on Hacker Rank for Free, if you are stuck anywhere between a compilation, just visit Queslers to get Python If-Else Hacker Rank Solution

Conclusion:

I hope this Python If-Else Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.

This Problem is intended for audiences of all experiences who are interested in learning Programming in a business context; there are no prerequisites.

Keep Learning!

More Hacker Rank Problem & Solutions >>

Staircase Hacker Rank Solution

A Very Big Sum Hacker Rank Solution

Diagonal Difference Hacker Rank Solution

Nested Lists Hacker Rank Solution

Lists Hacker Rank Solution

Leave a Reply

Your email address will not be published. Required fields are marked *