Python Day 3: Intro to Conditional Statements

Given an integer, n, perform the following conditional actions:

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
Complete the stub code provided in your editor to print whether or not is weird.

  1. #!/bin/python3
  2. import math
  3. import os
  4. import random
  5. import re
  6. import sys
  7. if __name__ == '__main__':
  8. N = int(input())
  9. if N%2!=0:
  10. print('Weird')
  11. elif N%2==0 and N in range(1,6):
  12. print('Not Weird')
  13. elif N%2==0 and N in range(5,21):
  14. print('Weird')
  15. elif N%2==0 and N>20:
  16. print('Not Weird')
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]

donate a cup of tea :)

Join Our Facebook Group

Share this solution is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube