본문 바로가기
코딩테스트/해커랭크

[easy] Python if-Else (with Python)

by mozi2 2022. 9. 30.
반응형

*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

*Input Format*

A single line containing a positive integer, N

*Output Format*

더보기
#!/bin/python3

 

import math
import os
import random
import re
import sys
 
if __name__ == '__main__':
 n = int(input().strip())

if n % 2 != 0:
    print ("Weird");
else:
    if n >= 2 and n <= 5:
        print ("Not Weird");
    elif n >= 6 and n <= 20:
        print ("Weird");
    elif n > 20:
        print ("Not Weird");
728x90
반응형