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...
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...
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...
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...
In this lab, you will write a program that creates a binary search tree based on...
In this lab, you will write a program that creates a binary search tree based on user input. Then, the user will indicate what order to print the values in. **Please write in C code** Start with the bst.h and bst.c base code provided to you. You will need to modify the source and header file to complete this lab. bst.h: #ifndef BST_H #define BST_H typedef struct BSTNode { int value; struct BSTNode* left; struct BSTNode* right; } BSTNode; BSTNode*...
-Data Structure in C++ (Review for C++) -using vector and class In this assignment you’re going...
-Data Structure in C++ (Review for C++) -using vector and class In this assignment you’re going to build a simple “register machine”, a kind of minimal computer that only supports storing a fixed number of values (i.e., no randomly-accessible “main memory”). Your machine will consist of an input loop that reads lines of input from the user and then executes them, stopping when the user quits (by executing the stop command). Each line of input consists of a command followed...
ANSWER IN C++ ONLY A string of characters including only alphabets (lowercase letters) is provided as...
ANSWER IN C++ ONLY A string of characters including only alphabets (lowercase letters) is provided as an input. The first task is to compute the frequency of each character appearing in the string. In the output, the characters have to be arranged in the same order as they appear in the input string. Then characters have to be rearranged, such that all the characters having a specific frequency, say xx, come together. Let the frequency of a character, lying in...
**please write code with function definition taking in input and use given variable names** for e.g....
**please write code with function definition taking in input and use given variable names** for e.g. List matchNames(List inputNames, List secRecords) Java or Python Please Note:    * The function is expected to return a STRING_ARRAY.      * The function accepts following parameters:      *  1. STRING_ARRAY inputNames      *  2. STRING_ARRAY secRecords      */ Problem Statement Introduction Imagine you are helping the Security Exchange Commission (SEC) respond to anonymous tips. One of the biggest problems the team faces is handling the transcription of the companies reported...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number of servings that are really possible with the included ingredients. Sometimes one will want to be able to scale those recipes upwards for serving larger groups. This program's task is to determine how much of each ingredient in a recipe will be required for a target party size. The first inputs to the program will be the recipe itself. Here is an example recipe...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT