If, else and elif are used to create conditional statement. As the name suggest the conditional statement are used to evaluate a condition. If a condition is evaluated to true a set of code runs else other set of code runs.
In this challenge, we’re getting started with conditional statements. Check out the Tutorial tab for learning materials and an instructional video!
Given an integer, n, perform the following conditional actions:
- If n is odd, print Weird
- If n is even and in the inclusive range 2 of 5 , print Not Weird
- If n is even and in the inclusive range 6 of 20 to, 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 n is weird.
A single line containing a positive integer, n.
- 1 <= n <=100
Print Weird if the number is weird; otherwise, print Not Weird.
Sample Input 0
Sample Output 0
Sample Input 1
Sample Output 1
n = int(input().strip()) if n%2 != 0: print('Weird') if n%2 == 0: if n>=2 and n<=5: print('Not Weird') if n>=6 and n<=20: print('Weird') if n>20: print('Not Weird')
Happy Coding ♥♥
Comment your Own Code ♥