Initial commit

This commit is contained in:
David Beazley
2023-07-16 20:21:00 -05:00
parent 82e815fab2
commit 7d4b30154a
259 changed files with 600233 additions and 2 deletions

41
Exercises/ex1_3.md Normal file
View File

@@ -0,0 +1,41 @@
\[ [Index](index.md) | [Exercise 1.2](ex1_2.md) | [Exercise 1.4](ex1_4.md) \]
# Exercise 1.3
*Objectives:*
- Review basic file I/O
*Files Created:* `pcost.py`
## (a) Working with files
The file `Data/portfolio.dat` contains a list of lines with information
on a portfolio of stocks. The file looks like this:
```
AA 100 32.20
IBM 50 91.10
CAT 150 83.44
MSFT 200 51.23
GE 95 40.37
MSFT 50 65.10
IBM 100 70.44
```
The first column is the stock name, the second column is the number of
shares, and the third column is the purchase price of a single share.
Write a program called `pcost.py` that opens this file, reads
all lines, and calculates how much it cost to purchase all of the shares
in the portfolio. To do this, compute the sum of the second column
multiplied by the third column.
\[ [Solution](soln1_3.md) | [Index](index.md) | [Exercise 1.2](ex1_2.md) | [Exercise 1.4](ex1_4.md) \]
----
`>>>` Advanced Python Mastery
`...` A course by [dabeaz](https://www.dabeaz.com)
`...` Copyright 2007-2023
![](https://i.creativecommons.org/l/by-sa/4.0/88x31.png). This work is licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/)