Python If-Else | Hacker Rank

Problem:

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


Solution:

#!/bin/python

import math
import os
import random
import re
import sys

#print(help(os))
#print(help(re))
#print(help(sys))
if __name__ == '__main__':
    n = int(raw_input().strip())
    if(n%2!=0):
        print('Weird')
    if(n%2==0):
        if((n>6 and n<21)):
            print('Weird')
        else:
            print('Not Weird')



    
    

Comments

Popular posts from this blog

Write a Function | Hacker Rank Solution in Python

Diagonal Difference | Hacker Rank Solution in C

Print Function | Hacker Rank Solution in Python