Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PURPOSE: Write a function named sumeven which takes two integer parameters named m and n. You may assumes that m n. The function will return
PURPOSE: Write a function named sumeven which takes two integer parameters named m and n. You may assumes that m n. The function will return the sum of all the even integers at least m and less than n. Use the given main function to test your function Hints: You will need to determine if m is an even number or an odd number. This can be accomplished using an if statement with the condition m % 2-0. If that condition is true, then m is even, otherwise m is odd. Use the above logic to adjust the value of m so that it is even. Use a for loop with the appropriate range function to generate the desired sequence of even numbers once you know that m is even. Look at lecture slides to find examples of adding a group of numbers together. # Put the sumeven function after this comment def main): # Get the inputs from the user mint(input ( 'Enter value for m: )) n-int(input ( 'Enter value for n: )) # Make sure m is less than or equal to n, if not then switch them if m> n: m, n n, # Calculate the sum of even numb res sum = sumeven (min) # Show the results print("The sum of the even numbers between %d and %d%(men), endw--') print('is %d'%sum)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started