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.
- Prepare
- Python
- Introduction
- Python If-Else
- Discussions
Python If-Else
Python If-Else
Sort by
recency
|
3860 Discussions
|
Please Login in order to post a comment
n = int(input()) 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 > 20): print("Not Weird") else: print("Weird")
n= 3
if n%2==0: if n in range(2,5): print('Not Weird') elif n in range(6,20): print('Weird') elif n > 20: print('Not Weird') else: print('Weird')
If n is odd, print "Weird".
If n is even and in the inclusive range of 2 to 5, print "Not Weird".
If n is even and in the inclusive range of 6 to 20, print "Weird".
If n is even and greater than 20, print "Not Weird".
n = int(input())
if n % 2 == 1: print("Weird") elif n in range(2, 6): print("Not Weird") elif n in range(6, 21): print("Weird") else: print("Not Weird")
!/bin/python3
import math import os import random import re import sys
if name == 'main': n = int(input().strip())
if n % 2 == 0 and n <= 1: print("Not Weird") if n % 2 != 0 and n <= 1: print("Weird") if n % 2 == 0 and 2 <= n <= 5: print("Not Weird")
if n % 2 != 0 and 2 <= n <= 5: print("Weird")
if n % 2 == 0 and 6 <= n <= 20: print("Weird")
if n % 2 != 0 and 6 <= n <= 20: print("Not Weird")
if n % 2 == 0 and n > 20: print("Not Weird") if n % 2 != 0 and n > 20: print("Weird")
n=int(input()) 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") elif n%2==0 and n>=20: print("Not weird")