Answer to Question #279331 in Python for Talha

Question #279331

Write a program in Python programming language, which allows the user to input integer values for variables named lowerLimit and upperLimit. Based on the input values, the program should perform the following tasks:



• Calculate and display all odd numbers within the given range (lowerLimit to upperLimit).


• Calculate and display all even numbers within the given range (lowerLimit to upperLimit).


• Calculate and display the number of total even and odd numbers present within the range (lowerLimit to upperLimit).



*lowerLimit and upperLimit are included within range.




1
Expert's answer
2021-12-13T16:57:14-0500
lowerLimit = int(input("Enter the lower limit: "))
upperLimit = int(input("Enter the upper limit: "))


numOdd = 0
print("There are odd numbers:")
for i in range(lowerLimit, upperLimit+1):
    if i%2 == 1:
        print(i, end=' ')
        numOdd += 1
print()

numEven = 0
print("There are even numbers:")
for i in range(lowerLimit, upperLimit+1):
    if i%2 == 0:
        print(i, end=' ')
        numEven += 1
print()

print("There are", numOdd, "odd numbers, and", numEven, " even numbers in totals")

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