URL : https://www.hackerrank.com/challenges/30-conditional-statements/problem
- Objective
- In this challenge, we’re getting started with conditional statements. Check out the Tutorial tab for learning materials and an instructional video!
- Task
Given an integer, n , perform the following conditional actions:
- If is odd, print Weird
- If is even and in the inclusive range of 2 to 5 , print Not Weird
- If is even and in the inclusive range of 6 to 20, print Weird
- If is even and greater than 20, print Not Weird
Complete the stub code provided in your editor to print whether or not n is weird.
Input Format
- A single line containing a positive integer, n.
- Constraints
- 1 <= n <=100
- Output Format
- Print Weird if the number is weird; otherwise, print Not Weird.
1
2
3
4
5
6
7
8
import math
import os
import random
import re
import sys
if __name__ == '__main__':
N = int(input())
1
24
1
2
3
4
5
6
7
8
9
N = 24
if N % 2 != 0:
print('Weird')
elif N <= 5:
print('Not Weird')
elif N <= 20:
print('Weird')
else:
print('Not Weird')
1
Not Weird
1
2
3
4
5
6
7
8
9
N = 3
if N % 2 != 0:
print('Weird')
elif N <= 5:
print('Not Weird')
elif N <= 20:
print('Weird')
else:
print('Not Weird')
1
Weird