Question: Python Programming Function save_history(history_list,landing_num) Use the Design Recipe to define a function save_history which consumes two parameters, a nested list and an int representing the

Python Programming

Function save_history(history_list,landing_num)

Use the Design Recipe to define a function save_history which consumes two parameters, a nested list and an int representing the current landing attempt. The function should open a new file named 'LandingNN.csv' where NN is two digits representing the current landing attempt. The first line should contain the number of sublists in the nested list. Each sublists should be written to the file on its own line with its values separated by commas. This function should close the file when its finished writing to it. Include a docstring!

For example:

Test
contents of file Landing01.csv
history =[ [3.61, 2.98, 15], [3.01, 0.6, 14], [0.79, 2.22, 14], [0, 3.84, 14]] save_history(history,1)
4 3.61,2.98,15 3.01,0.6,14 0.79,2.22,14 0,3.85,14

Note: When running your code, you can call the pre-defined function show_file_contents(filename) to view the contents of the file you saved.

For example - to view the contents of' Landing01.csv' use this statement:

show_file_contents('Landing01.csv')

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!