Answer to Question #320511 in Python for Carla May A. Laput

Question #320511

Create a program that contains two methods, one for displaying all even numbers from 1



to 10 and the other one displays all odd numbers from 1-10.

1
Expert's answer
2022-03-29T16:48:20-0400
def even_numbers():
    res = ""
    for i in range(1, 11):
        if(i % 2 == 0):
            res += str(i) + " "
    print(res)
    
def odd_number():
    res = ""
    for i in range(1, 11):
        if(i % 2 != 0):
            res += str(i) + " "
    print(res)


even_numbers()
odd_number()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS