Howdy!
Welcome to another day of my 30 days of code. Todays topic was conditional statements. I focused on keywords if & and to work through this problem. I also implemented pythons built in range function, which can take in 1, 2 or 3 parameters to work out if an element/variable is in a range of numbers. For this I used only two parameters each time.
The problem was, given an integer (n), work out if it was weird or not weird given these conditions:
- if n is odd, print 'Weird'
- if n is even, and in the range 2-5, print 'Not Weird'
- if n is even, and in the range 6-20, print 'Weird'
- if n is even, and greater than 20, print 'Not Weird'
Heres my solution:
Top comments (0)