Question

write a function printTable(start, nSteps, stepSize) that will print a table of x values and the...

write a function printTable(start, nSteps, stepSize) that will print a table of x values and the corresponding values of magic(x), one x value per line. Print nSteps lines in th etable, with the x values beginning at start and increasing by stepSize for each successive line.

simply ensure that the x and corresponding function value are separated by at least one space, as in this sample output:

3.1 1.1314021114

3.15 1.4740424529

3.2 1.1631508098

3.25 1.1786549963

Please using Python to solve! Thanks!

Homework Answers

Answer #1

Python Function:

def printTable(start, nSteps, stepSize):  
   """ Python Function that prints tabular form of values """
   # Initializing x value
   x = start
   # Iterating over nSteps
   for i in range(nSteps):
       # Printing current iteration values
       print(str(x) + " " + str(magic(x)))
       # Incrementing x value
       x = x + stepSize

Code Screenshot:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Q1) Write a Python function partial_print, which takes one parameter, a string, and prints the first,...
Q1) Write a Python function partial_print, which takes one parameter, a string, and prints the first, third, fifth (and so on) characters of the strings, with each character both preceded and followed by the ^ symbol, and with a newline appearing after the last ^ symbol. The function returns no value; its goal is to print its output, but not to return it. Q2) Write a Python function called lines_of_code that takes a Path object as a parameter, which is...
1. Compare the values of dy and Δy for the function. Function      x-Value      Differential...
1. Compare the values of dy and Δy for the function. Function      x-Value      Differential of x f(x) = 5x + 1      x = 1      Δx = dx = 0.01 dy = Δy = 2. Use differentials to approximate the change in profit corresponding to an increase in sales (or production) of one unit. Then compare this with the actual change in profit. Function      x-Value P = −0.2x3 + 800x − 80      x = 40...
Python #Write a function called are_anagrams. The function should #have two parameters, a pair of strings....
Python #Write a function called are_anagrams. The function should #have two parameters, a pair of strings. The function should #return True if the strings are anagrams of one another, #False if they are not. # #Two strings are considered anagrams if they have only the #same letters, as well as the same count of each letter. For #this problem, you should ignore spaces and capitalization. # #So, for us: "Elvis" and "Lives" would be considered #anagrams. So would "Eleven plus...
Python Write the contents of the function below. It should build a dictionary with keys and...
Python Write the contents of the function below. It should build a dictionary with keys and values. For each such entry, it must enter two rows from the keyboard. The first line should constitute the key to be stored in a form with only capital letters. The user enters the value on the next row. This should be stored as an integer. If you enter a blank line as the key, the lock should end and the dictionary is returned....
Using Python: Create a code to generate 1001 values between 0 and 10 (essentially, start from...
Using Python: Create a code to generate 1001 values between 0 and 10 (essentially, start from 0 and use increment 0.01) and for each value ? ∈ [0,10] calculate sin(?) and the derivative of ?(x) = sin(?) using the central difference method: ????(?)/?? = ?(?+0.01)−?(?−0.01) 2∙0.01 . Output the result in a file using the print command: print (?, ???(?) , ????(?), ??? =′ ′, ??? =′\ ? ′ , ???? = ??) Recall that the output file must be...
Your assignment is to write a c++ function that can calculate values for any 5 th...
Your assignment is to write a c++ function that can calculate values for any 5 th order polynomial function. ?(?) = ?0 + ?1? + ?2? 2+?3? 3 + ?4? 5 + ?5? 5 Your function should accept only two parameters, the first parameter should be the value of x at which to calculate y(x). The second parameter should be an array with 6 elements that contain the coefficients a0 to a5. The output of your function should be the...
Question: 1. Can the equation x = 5 be written as slope intercept form? Explain the...
Question: 1. Can the equation x = 5 be written as slope intercept form? Explain the reason(s). 2. What’s the relationship between two perpendicular lines in terms of slopes? Do you think this relationship is true for the perpendicular lines x = 0 and y =0? Why or why not? 3. How do you determine, from a graph of a function, if the function is even, odd or neither? 4. Suppose that a function f whose graph contains no breaks...
Calculate the Y values corresponding to the X values given below. Find the critical values for...
Calculate the Y values corresponding to the X values given below. Find the critical values for X for the given polynomial by finding the X values among those given where the first derivative, dy/dx = 0 and/or X values where the second derivative, d­2y/dx2 = 0. Be sure to indicate the sign (+ or -) of dy/dx and of d2y/dx2 tabled values. Reference Power Point Lesson 13 as needed. Using the first and second derivative tests with the information you...
Consider the function f(x)= x3 x2 − 4 Express the domain of the function in interval...
Consider the function f(x)= x3 x2 − 4 Express the domain of the function in interval notation: Find the y-intercept: y= . Find all the x-intercepts (enter your answer as a comma-separated list): x= . On which intervals is the function positive? On which intervals is the function negative? Does f have any symmetries? f is even;f is odd;    f is periodic;None of the above. Find all the asymptotes of f (enter your answers as equations): Vertical asymptote (left): ; Vertical...
Arrays, loops, functions: Lotto Element Repeated Function Write a function that that takes as parameters an...
Arrays, loops, functions: Lotto Element Repeated Function Write a function that that takes as parameters an array of ints, an int value named element, and an int value named end. Return a bool based on whether the element appears in the array starting from index 0 and up to but not including the end index. Generate Random Array Write a function that takes as parameters an array of integers and another integer for the size of the array. Create a...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT