In: Computer Science
Reminder, remember to code, evaluate, save, execute
(run), and check the Python program for possible errors. Remember
to create the sales.txt file with the following data (1000,
2000, 3000, 4000, 5000). Tip, the sales.txt file must be in
the same directory as the read_sales_text_file.py Python
program.
def main():
sales_file = open('sales.txt', 'r')
for line in sales_file:
amount = float(line)
print('$', format(amount, '.2f'))
sales_file.close()
main()
Output after you successfully run your code:
$ 1000.00
$ 2000.00
$ 3000.00
$ 4000.00
$ 5000.00
What you will submit:
Filename and extension:
read_sales_text_file.py
Filename and extension: sales.txt
File type(s): Python and .txt
def main():
with open('sales.txt', 'r') as sales_file:
for line in sales_file:
amount = float(line)
print('$', format(amount, '.2f'))
main()