Ask Question
28 January, 13:32

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!

+1
Answers (1)
  1. 28 January, 16:12
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers