Project 4: Stock Exchange Data
Questions & Answers
Why does the example output show the format but not actual numbers?
Because you could open up the file in Excel and figure out the answers easily without doing any programming. You should have the mindset that you COULD do this once in Excel, but what if you wanted to do this 1000 times a day? You want a program to do it instead.
My code is failing because the first line is headings, not numbers. How can I remove a heading line from my data?
Find a way to skip it. For example, if you read the file into a list of lines, the heading will be the first element. Remove it from the list.
How come stock prices have all those decimals, but you want the price formatted to look like dollars and cents?
The stock market is a volume business. Even one-thousandth of a cent per transaction adds up if you do 100 million transactions. If you round a transaction, someone is going to make money, and someone will lose money.
Can I use builtin functions and other modules to do stuff like max and min, or do I have to write all my own code?
Part of the lesson to be learned is to take advantage of what the language has to offer. That means it’s OK to use builtin functions and other modules here. We want you to explore what’s available to help you solve problems. CS majors will delve into the details later.
If I have a list lyst of items, how can I switch the order of elements easily?
One clean way is to write small function such as h, that takes a list as input, creates a copy of the list with the order changed and returns the changed list to the caller. While you could change the list in place and NOT return a value, best practice is to NOT change your inputs, rather return a changed copy.