Python If-Else

Do not have much time this morning so I just addressed the next challenge in the Python Introduction set at HackerRank named Python If-Else that you can find at:

This challenge tests the ability to write a set of correct if-then-else set of statements (including nested conditions).

Following is the output from IDLE for the test cases:

================================ RESTART: C:/Temp/ ================================

3 <== sample input



================================ RESTART: C:/Temp/ ================================

24 <== sample input

Not Weird


I am running on my development machine:

C:\> python -V

Python 3.5.2

My solution follows:

if __name__ == ‘__main__’:

n = int(input())

if (n % 2 == 1):

# **** odd number ****



# **** even number ****

if (n >= 2) and (n <= 5):

print(“Not Weird”)

elif (n >= 6) and (n <= 20):



print(“Not Weird”)

If you have comments or questions regarding this post or any other entry in this blog please do not hesitate and send me a message via email. Will answer as soon as possible and will not use your name unless you explicitly tell me to do so.



Follow me on Twitter: @john_canessa

Leave a Reply

Your email address will not be published. Required fields are marked *