Question: During the prove milestone for the previous lesson, you wrote the part of this program that reads and processes two CSV files, one named products.csv

During the prove milestone for the previous lesson, you wrote the part of this program that reads and processes two CSV files, one named products.csv that contains a catalog of products and one named request.csv that contains a customers order. During this prove assignment, you will add code to finish printing a receipt and to handle any exceptions that might occur while your program is running. Specifically, your program must do the following:
Print the store name at the top of the receipt.
Print the list of ordered items.
Sum and print the number of ordered items.
Sum and print the subtotal due.
Compute and print the sales tax amount. Use 6% as the sales tax rate.
Compute and print the total amount due.
Print a thank you message.
Get the current date and time from your computers operating system and print the current date and time.
Include a try block and except blocks to handle FileNotFoundError, PermissionError, and KeyError.
Helpful Documentation
The prove milestone describes the two CSV files that your program must process.
The preparation content for this lesson explains how to handle exceptions.
The datetime.now() method from the standard Python datetime module will get the current date and time from your computers operating system. Here is an excerpt from the official documentation for the datetime.now method:
datetime.now(tz=None)
Return the current local date and time.
tz is optional, but if it is not None, it must be a tzinfo (time zone information) object
These two Microsoft videos explain how to use methods from the standard datetime module.
Date data types (8 minutes)
Demonstration: Dates (9 minutes)
The following Python code imports the datetime class from the datetime module and calls the datetime.now method to get the current date and time from a computers operating system. Then it uses an f-string to format and print the current date and time.
# Import the datetime class from the datetime
# module so that it can be used in this program.
from datetime import datetime
# Call the now() method to get the current
# date and time as a datetime object from
# the computer's operating system.
current_date_and_time = datetime.now()
# Use an f-string to print the current
# day of the week and the current time.
print(f"{current_date_and_time:%A %I:%M %p}")
> python example_1.py
Tuesday 01:23 PM
After the computer executes line 8 in the above code, the variable current_date_and_time will hold the current date and time. Within the f-string at line 12, the string sequences that begin with the percent symbol (%) are called format codes. The format codes and their meaning are listed in the official Python datetime reference. As shown in the terminal window above, the previous example code will print the current day of the week and time to the terminal window.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!