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
+ 0 comments In python language
#!/bin/python3 import math import os import random import re import sys if __name__ == '__main__': N = int(input().strip()) if N%2!=0: print("Weird") elif(N%2==0 and N>=2 and N<=5): print("Not Weird") elif(N%2 == 0 and N >= 6 and N <= 20): print("Weird") else: print("Not Weird")
+ 0 comments python
if name == 'main': N = int(input().strip())
if N % 2 != 0: print("Weird") elif N % 2 == 0: if N >= 2 and N <= 5: print('Not Weird') elif N >= 6 and N <= 20: print('Weird') elif N > 20: print("Not Weird") else: print("Weird")
+ 0 comments function main() { const N = parseInt(readLine().trim(), 10); if (N % 2 != 0 && N >= 0){ console.log("Weird") }else if (N >= 2 && N <= 5){ console.log("Not Weird") }else if(N >= 6 && N <= 20){ console.log("Weird") }else{ console.log("Not Weird") } }
+ 0 comments function main() { const N = parseInt(readLine().trim(), 10);
if (N % 2 != 0 && N >= 0){ console.log("Weird") }else if (N >= 2 && N <= 5){ console.log("Not Weird") }else if(N >= 6 && N <= 20){ console.log("Weird") }else{ console.log("Not Weird") }
}
+ 0 comments #!/bin/python3 if __name__ == '__main__': n = int(input().strip()) # Checks if the number is odd or if it is even and between 6 and 20, inclusive. is_odd = (n % 2 != 0) is_inclusive_range = (6 <= n <= 20) # Print "Weird" when 'weird' conditional is True. Otherwise, it sets it to "Not Weird". weird_status = "Weird" if (is_odd or is_inclusive_range) else "Not Weird" print(weird_status)
Load more conversations
Sort 1699 Discussions, By:
Please Login in order to post a comment