Files
coding-mentor-agent/kb/python-course-kb-practical-python/wiki/exercises/3-12-using-your-library-module.md
T

45 lines
1.4 KiB
Markdown

---
id: practical-python-3.12
source_exercise_id: "3.12"
title: "Using your library module"
section: "3.4 Modules"
source_path: "03_Program_organization/04_Modules.md"
source_repo: "https://github.com/dabeaz-course/practical-python"
source_commit: "93dca856b41c61a0a0f85ae334116e4c125629ea"
student_visible_solution: false
has_private_solution: false
skip: false
---
# Exercise 3.12: Using your library module
> Source: Practical Python Programming, `03_Program_organization/04_Modules.md`.
### Exercise 3.12: Using your library module
In section 2, you wrote a program `report.py` that produced a stock report like this:
```
Name Shares Price Change
---------- ---------- ---------- ----------
AA 100 9.22 -22.98
IBM 50 106.28 15.18
CAT 150 35.46 -47.98
MSFT 200 20.89 -30.34
GE 95 13.48 -26.89
MSFT 50 20.89 -44.21
IBM 100 106.28 35.84
```
Take that program and modify it so that all of the input file
processing is done using functions in your `fileparse` module. To do
that, import `fileparse` as a module and change the `read_portfolio()`
and `read_prices()` functions to use the `parse_csv()` function.
Use the interactive example at the start of this exercise as a guide.
Afterwards, you should get exactly the same output as before.
## 关联来源
- [[summaries/04_Modules]]