Task
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
Solution:
import math import os import random import re import sys n = int(input()) if n%2!=0: print("Weird") elif 2<=n<=5: print("Not Weird") elif 6<=n<=20: print("Weird") elif n>20: print("Not Weird") |
Note:
This Code is Verified by all Test Cases.If any error occurs then Comment correct code Below in comment box.
Disclaimer:-
The above hole problem statement is given by hackerrank.com, but the solution is generated by the CodexRitik . if any of the query regarding this post or website fill the following contact form Thank You.
The above hole problem statement is given by hackerrank.com, but the solution is generated by the CodexRitik . if any of the query regarding this post or website fill the following contact form Thank You.
ReplyDelete
ReplyDeleteimport math
import os
import random
import re
import sys
n = int(input("your required no:"))
if n%2!=0:
print("Weird")
elif 2<=n<=5:
print("Not Weird")
elif 6<=n<=20:
print("Weird")
elif n>20:
print("Not Weird")
we have to put any string inside input(),and it will be converted into int. the above mentioned program will help user to put input as required. otherwise it won't execute.
ReplyDelete