Answered step by step
Verified Expert Solution
Question
1 Approved Answer
TASK 1 Your boss has asked you to help identify problems with a program he has made. # This program gets two numbers from the
TASK 1
Your boss has asked you to help identify problems with a program he has made.
# This program gets two numbers from the user and adds all even numbers between them # e.g. 10 (inclusive) and 18 (exclusive) = 10 + 12 + 14 + 16 (18 is skipped/excluded) rangeLow =int(input("What is the lowest number you'd like to add? (inclusive) ")) rangeLow =int(input("What is the highest number you'd like to add? (exclusive) ")) rangeSum =0 while(rangeLow <0): print("My minimum is 0 - please try again.") rangeLow int(input("What is the lowest number you'd like to add? (inclusive) ")) while(rangeHigh <=1000): print("My maximum is 1000 - please try again.") rangeHigh =int(input("What is the highest number you'd like to add? (exclusive) ")) if(rangeLow >= rangeHigh): print("The High number must be larger than Low number. I'll swap these for you.") temp = rangeHigh rangeHigh = rangeLow rangeLow = temp foriin loop(rangeLow, rangeHigh): # Even numbers have 0 remainder when divided by 2 - add these numbers, throw away the odds. The % operator gives us the remainder. if(i %2==0): print(" Adding "+str(i) +" to the sum.") rangeSum = rangeSum + i if(i > rangeHigh): print("My loop has gone past the High number! This shouldn't happen!") print("The sum of the even numbers from ["+str(rangeLow) +"] to ["+str(rangeHigh) +"] is: "+str(rangeSum)) |
- Identify a section of dead code and briefly describe why it/they will never be run.
- Identify at least one syntax error.
- Identify at least one logical/semantic error.
- Write 1-2 paragraphs of user-level and technical-level documentation.
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