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
|
1775 Discussions
|
Please Login in order to post a comment
The code is failing the test for 24 but when I test it using custom output it's passing for the same number? COuld someone point out what am I doing wrong here? n = 0 if n % 2 != 0: print('Weird') elif n % 2 == 0 and n in range(2,5): print('Not Weird') elif n % 2 == 0 and n in range(6,20): print('Weird') elif n % 2 == 0 and n in range(21,100): print('Weird') else: print('Weird')
!/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 in range(2,5): print("Not Weird") elif n % 2 == 0 and n in range(6,21): print("Weird") if n % 2 == 0 and n >20: print("Not Weird")
Python :
C# Solution, a one-line lamba expression:
Console.WriteLine(N % 2 == 0 && (N < 6 || N > 20) ? "Not Weird" : "Weird");