Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 4 ( Practice with Python ) Given a function of two parameters x and y , we want to create a file with a

Exercise 4(Practice with Python)
Given a function of two parameters x and y, we want to create a file with a table of function values. The left
column of the table contains y values in decreasing order as we go down the rows, and the last row contains
the x values in increasing order. That is, the first column and the last row act like numbers on an x and y axis
in a coordinate system. The rest of the table cells contains function values corresponding to the x and y
values for the respective rows and columns. For example, if the function formula is xC2y,x runs from 0 to 2
in steps of 0.5, and y run from 1 to 2 in steps of 1, the table looks as follows:
The task is to write a function:
def write_table_to_file(f, xmin, xmax, nx, ymin, ymax, ny,
width=10, decimals=None, filename='table.dat'):
where f is the formula, given as a Python function; x min, xmax, ymin, and ymax are the minimum and
maximum x and y values; nx is the number of intervals in the x coordinates (the number of steps in x
direction is then (xmax-xmin)/nx); ny is the number of intervals in the y coordinates; width is the width of
each column in the table (a positive integer); decimals is the number of decimals used when writing out the
numbers (None means no decimal specification), and file name is the name of the output file. For example,
width =10 and decimals =1 gives the output format %10.1g, while width =5 and decimals=None implies %5g.
Help me please
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

=+(f2-tf1) du 0, since the integrand is nonnegative.

Answered: 1 week ago

Question

2. How should this be dealt with by the organisation?

Answered: 1 week ago

Question

explain what is meant by the term fair dismissal

Answered: 1 week ago