Hackerrank
Hackerrank
Constraints
l<=n<=100
Output Format
Sample Input 0
3
Sample Output 0
Weird
Solution:
import math
import os
import random
import re
import sys
if __name__ == '__main__':
n = int(input().strip())
if n % 2 != 0:
print("Weird")
elif n % 2 == 0 and 2 <= n <= 5:
print("Not Weird")
elif n % 2 == 0 and 6 <= n <= 20:
print("Weird")
elif n % 2 == 0 and n > 20:
print("Not Weird")
2)The provided code stub reads two integers from STDIN, and . Add code to print
three lines where:
if __name__ == '__main__':
a = int(input().strip())
b = int(input().strip())
# Calculate the sum, difference, and product
sum_ab = a + b
diff_ab = a - b
prod_ab = a * b
3)The provided code stub reads two integers, and , from STDIN.
Add logic to print two lines. The first line should contain the result of integer
division, a//b
The second line should contain the result of float division, a/b.
if __name__ == '__main__':
a = int(input())
b = int(input())
4) The provided code stub reads and integer, , from STDIN. For all non-negative
integers i<n , print i square.
Example: n = 3
The list of non-negative integers that are less than n = 3 is [0,1,2] . Print the
square of each number on a separate line
if __name__ == '__main__':
n = int(input())