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.
Day 3: Intro to Conditional Statements
Day 3: Intro to Conditional Statements
Sort by
recency
|
1733 Discussions
|
Please Login in order to post a comment
In Java:
public class Solution { public static void main(String[] args) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
}
bufferedReader.close(); } }
In Python
N = int(input().strip()) if N% 2==0 and (2<=N<=5 or N>20): print("Not Weird") else: print("Weird")
IN javascript
function main() { const N = parseInt(readLine().trim(), 10); if (N % 2 !== 0) { console.log("Weird"); } else { 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"); } }
}
main
IN PYTHON ========================== def odd_even(number): if number%2 != 1: print("Weird") elif 2<=number<=5 or number% 2 == 0: print("Not weird") elif 6<=number<=20 or number% 2 == 0: print("weird") elif number>=20 or number% 2 == 0: print("Not weird") else: print("Weird") print(odd_even(22))
public static void main(String[] args) { Scanner sc=new Scanner(System.in);