Day 3: Intro to Conditional Statements

Types of Conditional Statements

Objective

In this challenge, we learn about conditional statements

Task

Given an integer, , 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

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')

'Python > HackerRank' 카테고리의 다른 글

Day 2 - Operators  (0) 2024.07.31