Posts

Showing posts with the label find the runner-up score

Python3 hackerRank exercise with solutions (Set 4)

1. Python If-Else  Given an integer, n, 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 format : A single line containing an integer N. (i.e.N>0) Output format : Print weird if the number is weird. Else print Not weird Sample input : 3 Sample output : Weird Code : n=int(input()) if((n>20)&(n%2==0)): print("Not weird") else: if(n%2==0): print("Not weird") if(n>2)&(n<5): print("Weird") elif(n<20)&(n>6): 2. Arithmetic Operators The code reads two integers a and b from user and print three lines where, the first line contains the sum of two integers, a+b the second line contains the difference of two integers, a-b the third line contains the product of two integers, a*b Input for