Question: Exercise 2.17: Store data in a nested list The purpose of this exercise is to store tabular data in two alternative ways, either as a

 Exercise 2.17: Store data in a nested list The purpose of

this exercise is to store tabular data in two alternative ways, either

Exercise 2.17: Store data in a nested list The purpose of this exercise is to store tabular data in two alternative ways, either as a list of columns or as a list of rows. In order to write out a nicely formatted table, one has to traverse the data, and the technique for traversal depends on how the tabular data is stored a) Compute two lists of t and y values as explained in Exercise 2.9. Store the two lists in a new nested list ty1 such that ty1 [0] and ty1[1] correspond to the two lists. Write out a table witht and y values in two columns by looping over the data in the ty1 list. Each number should be written with two decimals. b) Make a list ty2 which holds each row in the table of t and y values (ty1 is a list of table columns while ty2 is a list of table rows, as explained in Sect. 2.4). Loop over the ty2 list and write out the t and y values with two decimals each Filename: ball_table3 Exercise 2.8: Make a table of values from a formula The purpose of this exercise is to write code that prints a nicely formatted table of t and y(t) values, where Use n +1 uniformly spaced t values throughout the interval [0,2vol gl a) Use a for loop to produce the table. b) Add code with a while loop to produce the table. Hint Because of potential round-off errors, you may need to adjust the upper limit of the while loop to ensure that the last point (t-2vo/g. y -0) is included. Filename: ball_table1 Exercise 2.9: Store values from a formula in lists This exercise aims to produce the same table of numbers as in Exercise 2.8, but with different code. First, store the and y values in two lists t and y. Thereafter, write out a nicely formatted table by traversing the two lists with a for loop. Hint In the for loop, use either zip to traverse the two lists in parallel, or use an index and the range construction Filename: ball_table2 Exercise 2.17: Store data in a nested list The purpose of this exercise is to store tabular data in two alternative ways, either as a list of columns or as a list of rows. In order to write out a nicely formatted table, one has to traverse the data, and the technique for traversal depends on how the tabular data is stored a) Compute two lists of t and y values as explained in Exercise 2.9. Store the two lists in a new nested list ty1 such that ty1 [0] and ty1[1] correspond to the two lists. Write out a table witht and y values in two columns by looping over the data in the ty1 list. Each number should be written with two decimals. b) Make a list ty2 which holds each row in the table of t and y values (ty1 is a list of table columns while ty2 is a list of table rows, as explained in Sect. 2.4). Loop over the ty2 list and write out the t and y values with two decimals each Filename: ball_table3 Exercise 2.8: Make a table of values from a formula The purpose of this exercise is to write code that prints a nicely formatted table of t and y(t) values, where Use n +1 uniformly spaced t values throughout the interval [0,2vol gl a) Use a for loop to produce the table. b) Add code with a while loop to produce the table. Hint Because of potential round-off errors, you may need to adjust the upper limit of the while loop to ensure that the last point (t-2vo/g. y -0) is included. Filename: ball_table1 Exercise 2.9: Store values from a formula in lists This exercise aims to produce the same table of numbers as in Exercise 2.8, but with different code. First, store the and y values in two lists t and y. Thereafter, write out a nicely formatted table by traversing the two lists with a for loop. Hint In the for loop, use either zip to traverse the two lists in parallel, or use an index and the range construction Filename: ball_table2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!