This will be done using Python. Write each of the following functions using Python. The function...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
This will be done using Python. Write each of the following functions using Python. The function header MUST be written as specified. In your main code test all of the specified functions. Each function must have a comment block explaining what it does, what the parameters are and what the return value is. Please remember the following two guidelines: unless the purpose of the function is to generate output DO NOT write to the screen within the function (output for debugging purposes does not apply) unless the purpose of the function is to ask the user for a value DO NOT ask the user for a value within the function Required functions def square (intValue): This function returns the square of intValue. def summation (intValue): This function returns the summation of 1 to intValue. You can assume that intValue will be positive. For example, summation (5) would return 15 (1+ 2+ 3+ 4+ 5). def sumOfSquare (intValue): This function return the sum of the squares from 1 to intValue. For example, sumOfSquares (5) would return 55 (1 + 4+9+16+ 25). You MUST use a loop and the square function to determine the returned value. def factorial (intValue): This function returns the factorial of 1 to intValue. You can assume that intValue will be positive. For example, factorial (5) would return 120 (1 *2*3*4*5). def distance (x1, y1, x2, y2): This function returns the distance between two points. x1, y1 will be the first point, and x2, y2 will be the second point. The formula is distance = (x2 x1)+(y y1). You will want to look at the functions offered by the Math class to help with this formula. def isOdd (int intValue): This function will return True if intValue is odd, otherwise it returns False. def isEven (intValue): This function will return True if intValue is even, otherwise it return False. This function MUST use isOdd to determine the returned value. The point behind this function is to minimize the amount of redundant work that is done in our code, not that determining odd or even is a lot of work. It's the concept more than the reality of the code in this case. This will be done using Python. Write each of the following functions using Python. The function header MUST be written as specified. In your main code test all of the specified functions. Each function must have a comment block explaining what it does, what the parameters are and what the return value is. Please remember the following two guidelines: unless the purpose of the function is to generate output DO NOT write to the screen within the function (output for debugging purposes does not apply) unless the purpose of the function is to ask the user for a value DO NOT ask the user for a value within the function Required functions def square (intValue): This function returns the square of intValue. def summation (intValue): This function returns the summation of 1 to intValue. You can assume that intValue will be positive. For example, summation (5) would return 15 (1+ 2+ 3+ 4+ 5). def sumOfSquare (intValue): This function return the sum of the squares from 1 to intValue. For example, sumOfSquares (5) would return 55 (1 + 4+9+16+ 25). You MUST use a loop and the square function to determine the returned value. def factorial (intValue): This function returns the factorial of 1 to intValue. You can assume that intValue will be positive. For example, factorial (5) would return 120 (1 *2*3*4*5). def distance (x1, y1, x2, y2): This function returns the distance between two points. x1, y1 will be the first point, and x2, y2 will be the second point. The formula is distance = (x2 x1)+(y y1). You will want to look at the functions offered by the Math class to help with this formula. def isOdd (int intValue): This function will return True if intValue is odd, otherwise it returns False. def isEven (intValue): This function will return True if intValue is even, otherwise it return False. This function MUST use isOdd to determine the returned value. The point behind this function is to minimize the amount of redundant work that is done in our code, not that determining odd or even is a lot of work. It's the concept more than the reality of the code in this case.
Expert Answer:
Posted Date:
Students also viewed these programming questions
-
What is the significance of communication between managers and their subordinates, and how does it impact employee performance?
-
A rectangular work piece has the following original dimensions: 2a = 100 mm, h = 30 mm, and width = 20 mm. The metal has a strength coefficient of 300 MPa and a strain-hardening exponent of 0.3. It...
-
Discuss the advantages and disadvantages of the direct method, the step method and the linear algebra method in the allocation of service department costs to production departments
-
Which of the following assertions is accurate concerning the IAASB? (a) The International Auditing and Assurance Standards Board (IAASB) is an independent standard-setting body that serves the public...
-
Multiple Choice Questions The following questions concern accumulating evidence in the acquisition and payment cycle. Choose the best response. a. In auditing accounts payable, an auditors procedures...
-
Quick ratio Adieu Company reported the following current assets and current liabilities for two recent years: Dec. 31, 20Y4 Dec. 31, 20Y3 Cash Temporary investments Accounts receivable Inventory...
-
The Securities and Exchange Commission has determined that the number of companies listed on the PSE declaring bankruptcy is approximately a Poisson distribution with a mean of 2.5 per month. Find...
-
Peter Co uses a periodic inventory system and purchases (use 4 decimal points for unit cost) for the month of August were: Date Units Unit cost $ Beginning Inventory 1-Aug 2900 2.226 Purchase 10-Aug...
-
In social media in sport, discuss the AISAM Model in digital marketing with specific examples?
-
What sales volume is required at a retail price of Cr. 6.85 to give the same incremental profit as selling 30 tons at a retail price of Cr. 8.20?
-
If you were a participant in this stud & you were offered $100 to lose 30lbs or, $175 to go to the gym for 30 straight days, with no loss of weight requirements, which would you choose? Tell me why...
-
1. A survey carried out by the professional engineers describes several characteristics of fuel rods used in a reactor owned by an electric utility in Damansara. From the record, the true standard...
-
Patrick received 2,000 shares of restricted stock on April 1, 2021 when the stock was valued at $105 per share. The shares vested on April 1, 2022 when the stock was valued at $126 per share. If...
-
Classify each of the following activities as proper or prohibited under the various consumer statutes you have studied. a. Calling a hospital room to talk to a debtor who is a patient there. b....
-
A superball is dropped from a 2.00 m height. After it rebounds, it reaches a new height of 1.65 m. Assuming a constant coefficient of restitution, find the (ideal) total distance the ball will travel...
-
Here are some telescoping series problems: a. Verify that \[\sum_{n=1}^{\infty} \frac{1}{(n+2)(n+1)}=\sum_{n=1}^{\infty}\left(\frac{n+1}{n+2}-\frac{n}{n+1} ight)\] b. Find the \(n\)th partial sum of...
-
Determine the radius and interval of convergence of the following infinite series: a. \(\sum_{n=1}^{\infty}(-1)^{n} \frac{(x-1)^{n}}{n}\). b. \(\sum_{n=1}^{\infty} \frac{x^{n}}{2^{n} n!}\). c....
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App