- Prepare
- Python
- Introduction
- Python If-Else
- Discussions
Python If-Else
Python If-Else
+ 0 comments what is the error in my code
if (n%2!=0): print("Weird") elif(n>=2 and n<=5): if(n%2==0): print("Not Weird") elif(n>=6 and n<=20): if(n%2==0): print("Weid") elif(n>20): if(n%2==0): print("Not Weird")
+ 0 comments import math import os import random import re import sys
if name == 'main': n = int(input().strip()) assert (n >= 0 and n <= 100) if(n%2!=0): print("Weird") elif(n%2==0)&((n>=2)and(n>=5)): print("Not Weird") elif(n%2==0)&((n>=6)and(n<=20)): print("Weird")
elif(n%2==0)&(n>20): print("Not Weird")
+ 0 comments why not accepted
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 Dont forget the assert statement at the start!
n = int(input().strip()) assert (n >= 0 and n <= 100) if n % 2 != 0 or (n >= 6 and n <= 20 and n % 2 == 0): print("Weird") elif n % 2 == 0 and ((n >= 2 and n <= 5) or n > 20): print("Not Weird")
+ 0 comments if __name__ == '__main__': n = int(input().strip()) print("Weird" if n % 2 != 0 or 6 <= n <= 20 else "Not Weird")
Sort 3348 Discussions, By:
Please Login in order to post a comment