Day 3: Intro to Conditional Statements

Sort by

recency

|

1772 Discussions

|

  • + 0 comments

    Python :

    N = int(input().strip())
    if (N % 2 != 0) or (N in range(6,21)):
        print("Weird")
    else:
        print("Not Weird")
    
  • + 0 comments

    C# Solution, a one-line lamba expression:

    Console.WriteLine(N % 2 == 0 && (N < 6 || N > 20) ? "Not Weird" : "Weird");

  • + 0 comments

    javascript

    let n;

    if(n%2 != 0){ console.log("Weird");}

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

     i did like that but 24 return weird i dont know why i tried on visual studio code it return Not weird, anybody know thats why?
    

    }

  • + 0 comments

    JAVA

    Solution

    public class Solution {
        public static void main(String[] args) throws IOException {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
    
            int N = Integer.parseInt(bufferedReader.readLine().trim());
            
            if(N%2!=0){
            System.out.print("Weird");
        }
        if(N%2==0 && N>=2 && N<=5){
            System.out.print("Not Weird");
        }
        if(N%2==0 && N>=6 && N<=20){
            System.out.print("Weird");
        }
        if(N%2==0 && N>20){
            System.out.print("Not Weird");
        }
    
            bufferedReader.close();
        }
    
  • + 0 comments
    if __name__ == '__main__':
        N = int(input().strip())
        if N % 2 != 0 or 6 <= N <= 20:
            print('Weird')
        else:
            print('Not Weird')