Day 3: Intro to Conditional Statements

Sort by

recency

|

1782 Discussions

|

  • + 0 comments

    function main() { const N = parseInt(readLine().trim(), 10); let result = "Weird";

    if (N % 2 != 0) {
        result = "Weird";        
    }else if ( N >=2 && N <= 5) {
        result = "Not Weird"; 
    }else if (N >= 6 && N <= 20 ) {
        result = "Weird"; 
    }else {
        result = "Not Weird"; }
    
    console.log(result);
    

    }

  • + 0 comments
    def weird_test(n):
        if (n % 2 != 0) or(6 <= n <= 20):
            print("Weird")
        else:
            print("Not Weird")
    
  • + 0 comments

    My solution is as follows:

    if __name__ == '__main__':
        N = int(input().strip())
        if N%2==1:
            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")
        else:
            print("you entered the number out of constraint (1=<N=>100")
    
  • + 0 comments

    Intro To Condition if(N % 2 === 0){ if(N>2 && N<5){ console.log("Not Weird"); }else if(N>6 && N<=20){ console.log("Weird"); }else if (N > 20){ console.log("Not Weird"); } }else if (N % 2 !== 0){ console.log("Weird"); }

  • + 0 comments

    there is some problem with 24, I think, it is passing for me on my pycharm.