Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Python program that uses for loops to perform the following steps. a. Prompt the user to input two positive integers (no zero or

Write a Python program that uses for loops to perform the following steps.

a. Prompt the user to input two positive integers (no zero or negative). variables: firstNum and secondNum (firstNum must be less than secondNum). Validate the user's input; prompt the user again if firstNum is not less than secondNum (use for loop). b. Output all odd numbers between firstNum and secondNum. (use for loop). c. Output the sum of all even numbers between firstNum and secondNum. (use for loop). d. Output the sum of the square of the odd numbers between firstNum and secondNum. (use for loop)

OUTPUT:

Enter two positive integer numbers. First number must be less than the second number you enter Enter numbers: 1 9 Odd integers between 1 and 9 are: 1 3 5 7 9 Sum of even integers between 1 and 9 = 20 Sum of the squares of odd integers between 1 and 9 = 165 Do you want to repeat this program? y/n > y
Enter two positive integer numbers. First number must be less than the second number you enter Enter numbers: 11 15 Odd integers between 11 and 15 are: 11 13 15 Sum of even integers between 11 and 15 = 26 Sum of the squares of odd integers between 11 and 15 = 515 Do you want to repeat this program? y/n > n Bye!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions