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
+ 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') elif n>20: print('Not weird')
+ 0 comments #!/bin/python3 import math import os import random import re import sys n = 3 if __name__ == '__main__': n = int(input().strip()) if n % 2 != 0: print("Weird") elif n % 2 == 0 and 2 <= n <= 5: print("Not Weird") elif n % 2 == 0 and 6 <= n <= 20: print("Weird") elif n % 2 == 0 and n > 20: print("Not Weird")
+ 0 comments #!/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") else: if((n>=2 and n<=5) or (n > 20) ): print("Not Weird") else: print("Weird")
+ 0 comments Python If-Else
enter_number = int(input()) if enter_number % 2 != 0: print('Weird') elif enter_number>= 2 and enter_number <= 5: print('Not Weird') elif enter_number % 2 == 0 and enter_number>= 6 and enter_number <= 20: print('Weird') elif enter_number > 20: print('Not Weird')
+ 1 comment def weirdornot(): num = int(input()) if num%2 == 1: print("Weird") elif num%2 == 0 and range(2,5): print("Not Weird") elif num%2 == 0 and 6<=num<=20: print("Weird") elif num%2 == 0 and num>20: print("Not Weird") def main(): weirdornot() if __name__ == "__main__": main()
Instead of
2<=num<=5
&6<=num<=20
you can userange(2,6) & range(5,21)
Load more conversations
Sort 3645 Discussions, By:
Please Login in order to post a comment