Sort by

recency

|

4382 Discussions

|

  • + 0 comments

    n = int(input().strip()) if n%2!=0: print("Weird") # for getting the odd value else: if n%2==0: # for getting even value if n in range(2,6): # these are the if conditions which were asked later and hint was given as the range from 2 to 6 etc print("Not Weird") if n in range(6,21): print("Weird") if n>20: print("Not Weird")

  • + 1 comment

    Why did this fail:

    if __name__ == '__main__':
        n = int(input().strip())
        if n % 2 != 0:
            print("Weird")
        elif n % 2 == 0:
            if 2<= n <= 5:
                print("Not Weird")
            elif 6<= n <= 20:
                print("Weird")
            else:
                print("Not Weird")
    
    • + 1 comment

      the last condition shouldn't be else but elif n > 20. Get it?

      • + 0 comments

        i don't understand, why doesnt the "else" work to catch the last possible case which is n = even number that is more than 20 ?

  • + 0 comments

    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 Input Format

    A single line containing a positive integer, .

  • + 0 comments

    if n % 2 == 1 or 6<=n<=20: print("Weird") else: print("Not Weird")

  • + 0 comments
    n = int(input())  #This allows for the user/system to enter a number to test
    
    if n % 2 == 0:
        if n in range(2, 6):  #This is inclusive of 2 to 5 (meaning, it stops at 6)
            print("Not Weird")
        elif n in range(6, 21): #This is inclusive of 6 to 20 (meaning, it stops at 21)
            print("Weird")
        else:
            print("Not Weird")
    else:
        print("Weird")