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 Kotlin
fun main(args: Array) { val N = readLine()!!.trim().toInt()
if(N>=1 && N<=100) { if(N%2==0) { if(N in 2..5) { println("Not Weird")} else if(N in 6..20) {println("Weird")} else if(N>20) {println("Not Weird") } } else { println("Weird") } }
}
+ 0 comments import java.util.Scanner; class Solution{ public static void main(String [] args){ Scanner sc = new Scanner(System.in); int a = sc.nextInt(); if(a<6){ if(a%2==0) System.out.println("Not Weird"); else System.out.println("Weird"); } else if(a<21) System.out.println("Weird"); else if(a>20){ if(a%2==0) System.out.println("Not Weird"); else System.out.println("Weird"); } } }
[deleted] + 0 comments Got stuck in finding the modulo operator, was trying with division instead and, well it took some time, long story short; still unupdated about name == main; here's the code:
#!/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 (2 <= N | N <= 5): print("Not Weird") elif (6<= N | N <= 20): print("Weird") elif(N > 20): print("Not Weird")
+ 0 comments Python
if N % 2 != 0: print("Weird") elif N % 2 == 0 and N in range(6,21): print("Weird") else: print("Not Weird")
+ 0 comments n=int(input()) if n%2!=0: print('Weird') else: if(n>=2 and n<5): print("Not Weird") elif n>=6 and n<=20: print("Weird") else: print("Not Weird")
Load more conversations
Sort 1632 Discussions, By:
Please Login in order to post a comment