Loading

[NEW SOLN] FUNDAMENTALS OF PYTHON CHAPTER 6 PROJECT 6 7 8 9

[SOLVED] FUNDAMENTALS OF PYTHON CHAPTER 6 PROJECT 6 7 8 9: These projects must be done in the latest version of IDLE:

6. Add a command to this chapter’s case study program that allows the user to view the contents of a file in the current working directory. When the command is selected, the program should display a list of filenames and a prompt for the name of the file to be viewed. Be sure to include error recovery.

[SOLVED] FUNDAMENTALS OF PYTHON CHAPTER 6 PROJECT 6 7 8 9: 7.�Write a recursive function that expects a pathname as an argument. The pathname can be either the name of a file or the name of a directory. If the pathname refers to a file, its name is displayed, followed by its contents. Otherwise, if the pathname refers to a directory, the function is applied to each name in the directory. Test this function in a new program.

[SOLVED] FUNDAMENTALS OF PYTHON CHAPTER 6 PROJECT 6 7 8 9: 8.�Lee has discovered what he thinks is a clever recursive strategy for printing the elements in a sequence (string, tuple, or list). He reasons that he can get at the first element in a sequence using the 0 index, and he can obtain a sequence of the rest of the elements by slicing from index 1. This strategy is realized in a function that expects just the sequence as an argument. If the sequence is not empty, the first element in the sequence is printed and then a recursive call is executed. On each recursive call, the sequence argument is sliced using the range 1:. Here is Lee’s function definition:
def printAll(seq):
if seq:
print seq[0]
printAll(seq[1:])
[SOLVED] FUNDAMENTALS OF PYTHON CHAPTER 6 PROJECT 6 7 8 9: Write a script that tests this function and add code to trace the argument on each call. Does this function work as expected? If so, explain how it actually works, and describe any hidden costs in running it.

9. Write a program that computes and prints the average of the numbers in a text file. You should make use of two higher-order functions to simplify the design.

Support