please use python 1. Use functions from the Python math module Write a program (MathFunctions.py) that prints
Fantastic news! We've Found the answer you've been seeking!
Question:
please use python
Transcribed Image Text:
1. Use functions from the Python math module Write a program (MathFunctions.py) that prints a table of values for the absolute value of x and for 2* values from -10 to 10. Use a for loop to print the table. Per iteration one line of the table will be printed. You do not need to define your own function here. Use the pow function and the fabs function as described in the math module of Python. You need to import the math module (see slide 6) before you can use the functions. For the header line of the table use the following print statement (one time, before the loop): print ("x" + "\t" + "abs(x)" + "\t" + "pow(2,x)"). "\t" can be used to print the tab-stops (the big blank spaces, between the words or numbers). The output of your program will look like this: x fabs (x) pow(2,x) -10 10.0 0.0009765625 9.0 0.001953125 8.0 0.00390625 7.0 0.0078125 6.0 0.015625 5.0 0.03125 4321 IIIO 123456789 4.0 0.0625 3.0 0.125 2.0 0.25 1.0 0.5 0.0 1.0 1.0 2.0 2.0 4.0 3.0 8.0 4.0 16.0 5.0 32.0 6.0 64.0 7.0 128.0 8.0 256.0 9.0 512.0 10 10.0 1024.0 1. Use functions from the Python math module Write a program (MathFunctions.py) that prints a table of values for the absolute value of x and for 2* values from -10 to 10. Use a for loop to print the table. Per iteration one line of the table will be printed. You do not need to define your own function here. Use the pow function and the fabs function as described in the math module of Python. You need to import the math module (see slide 6) before you can use the functions. For the header line of the table use the following print statement (one time, before the loop): print ("x" + "\t" + "abs(x)" + "\t" + "pow(2,x)"). "\t" can be used to print the tab-stops (the big blank spaces, between the words or numbers). The output of your program will look like this: x fabs (x) pow(2,x) -10 10.0 0.0009765625 9.0 0.001953125 8.0 0.00390625 7.0 0.0078125 6.0 0.015625 5.0 0.03125 4321 IIIO 123456789 4.0 0.0625 3.0 0.125 2.0 0.25 1.0 0.5 0.0 1.0 1.0 2.0 2.0 4.0 3.0 8.0 4.0 16.0 5.0 32.0 6.0 64.0 7.0 128.0 8.0 256.0 9.0 512.0 10 10.0 1024.0
Expert Answer:
Posted Date:
Students also viewed these programming questions
-
Simplify the expression 2x + (x + 1) into a single x + 1 fraction. The numerator of your answer is: The denominator of your answer is:
-
It was stated that graphite is the generally preferred material for EDM tooling. Would graphite also be appropriate for wire EDM? Explain.
-
High Company issued \(\$ 100,000\) face value of bonds on January 1, 2011. The bonds had a 5 percent stated rate of interest and a 10-year term. Interest is paid in cash annually, beginning December...
-
You are offered the opportunity to buy a note for \($12,800.\) The note is certain to pay \($2,000\) at the end of each of the next 10 years. If you buy the note, what rate of interest will you...
-
Historical demand for a product is as follows: Demand April ............. 60 May ............. 55 June ............. 75 July ............. 60 August ............. 80 September ............. 75 a....
-
. TRUE/FALSE. Write 'T' if the statement is true and 'F' if the statement is false.. 3) 3) The margin of safety may be expressed in units, dollars, or as a percentage.. 5) A contribution margin...
-
what is SD-WAN (Software-Defined WAN).? what they are, their various applications, their advantages & disadvantages, and how they are or will be used by networking vendors?
-
What initial challenges did you encounter with the client that could be overcome with our product?
-
Kayak Company budgeted the following cash receipts (excluding cash receipts from loans received) and cash payments excluding cash payments for loan principal and interest payments) for the first...
-
why is the NPV method is the preferred method as it considers the time value of money (although it is more difficult to compute!). What variables are use to calculate the NPV?
-
Use the simplex method to maximize the function under the given constraints. (If the solution is unbounded, enter INFINITY.) Maximize f = 3x + y subject to 4x + y 44 4x + 3y 60 x 0, y 0. f = INFINITY
-
Selected accounts with some amounts omitted are as follows Work in Process Aug. 1 Balance 271,500 Aug. 31 Goods finished 179,600 31 Direct materials X 31 Direct labor 46,700 31 Factory overhead X...
-
Mike and Maria are 44 years old. Mike owns a sole-proprietorship with gross revenue of $245,000 and total expenses of $73,500, resulting in a net profit of $171,500. Mike's net income equals the fees...
-
Why did management adopt the new plan even though it provides a smaller expected number of exposures than the original plan recommended by the original linear programming model?
-
8. Ryder leased a truck to Florida Food Service; Powers, an employee, drove it to make deliveries. He noticed that the door strap used to close the rear door was frayed, and he asked Ryder to fix it....
-
9. A new truck, manufactured by General Motors Corp. (GMC), stalled in rush hour traffic on a busy interstate highway because of a defective alternator, which caused a complete failure of the truck's...
-
10. A prison inmate bit a hospital employee. The employee sued the state for negligence and lack of supervision, claiming a fear of AIDS. The plaintiff had tested negative for HIV three times, and...
Study smarter with the SolutionInn App