Python If-Else | HackerRank
Practice using if-else conditional statements
www.hackerrank.com
Goal
You need to print "Weird" if the number is weird in under condition. Otherweise, print "Not Weird".

Solution
You can follow what conditions say, then it would be easy.
# Python If-Else
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')
else:
print('Not Weird')
'software Engineering > (Python)HackerRank' 카테고리의 다른 글
| [Python] HackerRank - Write a function (0) | 2023.01.26 |
|---|---|
| [Python] HackerRank - Loops (0) | 2023.01.21 |
| [Python] HackerRank - Python: Division (0) | 2023.01.20 |
| [Python] HackerRank - Arithmetic Operators (0) | 2023.01.19 |
| [Python] HackerRank - Say "Hello, World!" With Python (0) | 2023.01.19 |