Single-Line Comments
We'll cover the following...
Single-line comments
Single-line comments can be added by simply putting the hash symbol before the comment.
Let's take a look at an example that displays a message on the screen. This code uses comments to describe the functionality.
Multiple single-line comments
In Python, we can add as many comments as we want to describe the working of the code.
For instance, this piece of code calculates the amount of work to be done in a day work_per_day using information such as total_work, my_progress_so_far, days_spent, and all_days. It consists of multiple single-line comments, and the format for each comment remains the same.
Note: The
.3fin the{work_per_day:.3f}statement allows us to specify the number of decimal places to print. In this case,work_per_dayis printed up to three decimal places.