We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Python
  3. Introduction
  4. Python If-Else
  5. Discussions

Python If-Else

Problem
Submissions
Leaderboard
Discussions
Editorial
Tutorial

Sort 3121 Discussions, By:

recency

Please Login in order to post a comment

  • iamnaushadhk
    6 hours ago+ 0 comments

    if name == 'main':

    n = int(input().strip())
    

    if n%2!=0: print("Weird") elif (n%2==0) and n in range(1,6): print("Not Weird") elif (n%2==0) and n in range(5,21): print("Weird") elif (n%2==0) and (n>20): print("Not Weird")

    0|
    Permalink
  • sdevadoss1
    22 hours ago+ 0 comments
    if n % 2 == 1:
        print("Weird")
    else:    
        if n % 2 == 0 and 2 <= n <= 5:
            print("Not Weird")
        else:
            if n % 2 == 0 and 6 <= n <= 20:
                print("Weird")
            elif n % 2 == 0 and n >= 20:
                print("Not Weird")
    
    0|
    Permalink
  • boyinavarasiddi1
    2 days ago+ 0 comments

    Hey there, can someone please help out on how to code the if - else (python) part where you have 'n' as even or odd and then you print it accordingly. If you know it, then please help me understand the process. Thank you : )

    0|
    Permalink
  • kfkanta20
    3 days ago+ 0 comments

    Anyone let me know where I did mistake?

    n=int(input()) if 1<=n<=100: if n%2==0 and n>20: print("Not Weird") elif n%2==0 and 6>=n<=20: print("Weird") elif n%2==0 and 2>=n<=5: print("not Weird") elif n%2==1: print("weird")

    0|
    Permalink
  • sathi_satb
    4 days ago+ 0 comments

    can we not use the range function here?

    0|
    Permalink
Load more conversations

Need Help?


View tutorial
View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy