Python Day 3 : Intro to Conditional Statements | HackerRank 30 Days of Code Solutions


 

Given an integer, n, perform the following conditional actions:

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
Complete the stub code provided in your editor to print whether or not is weird.

Code:

#!/bin/python3

import math
import os
import random
import re
import sys


if __name__ == '__main__':
    N = int(input())
    if N%2!=0:
        print('Weird')
    elif N%2==0 and N in range(1,6):
        print('Not Weird')
    elif N%2==0 and N in range(5,21):
        print('Weird')
    elif N%2==0 and N>20:
        print('Not Weird')
AJ Blogs

Hello everyone, My name Arth and I like to write about what I learn. Follow My Website - https://sites.google.com/view/aj-blogs/home

Post a Comment

Previous Post Next Post
Best Programming Books

Facebook

AJ Facebook
Checkout Our Facebook Page
AJ Blogs
Checkout Our Instagram Page