Ask Question
2 February, 12:28

We will pass in a value N. Ouput every even value between 0 and N. Tip: you may remember the modulo operator. 10 % 3 returns the remainder of 10 divided by 3. You can use this in a decision to determine whether a number is odd or even. Just think about what makes an even number even and all should become clear!

+5
Answers (1)
  1. 2 February, 15:23
    0
    def odd_even (N):

    for number in range (0, N+1):

    if number % 2 = = 0:

    print (str (number) + " is even")

    elif number % 2 = = 1:

    print (str (number) + " is odd")

    odd_even (5)

    Explanation:

    - Create a method called odd_even that takes one parameter, N

    - Initialize a for loop that iterates through 0 to N

    Inside the loop, check if module of the number with respect to 2 is equal to 0. If yes, print it as even number. If module of the number with respect to 2 is equal to 1, print it as odd number

    Call the method
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “We will pass in a value N. Ouput every even value between 0 and N. Tip: you may remember the modulo operator. 10 % 3 returns the remainder ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers