Comments are extremely useful feature in most programming languages.
Everything you have written in your program so far is Python code.
As your programs become longer and more complicated, you should add nodes.
Within your programs that describe your overall approach to the problems you're solving?
So a comment allows you to write notes in your spoken language within your programs.
So how do how do you write comments?
So in Python, the hash mark here.
The hash mark.
Let's actually let's use a different color.
Yes.
So the hash mark.
Indicates a comment.
Anything following a hash mark in your code is ignored by the python interpreter here.
As you can see, we got an error here.
That's because in reality my value doesn't exist.
If we comment this, it will not compile.
So.
Let's do something here.
So.
Hello.
Oxley students here.
So.
And print.
Hello Python people and let's run it.
And as you can see, we are seeing only our.
Um, print function and Python ignores the first line and executes the third line.
So what kinds of comments should we should you write?
So the main reason to write comments is to explain what your code is supposed to do and how you are
making it work.
So when you are in the middle of working on a project, you understand how all of the pieces fit together.
But when you return to a project after some time away, you will likely have forgotten some of the details,
right?
So you can always tidy your code for a while and figure out how segments you were supposed to work.
But writing good comments can save you time by summarizing your overall approach clearly.
If you want to become a professional programmer or elaborate with other programmers, you should write
meaningful comments.
Today, most software is written collaboratively, whether by a group of employees at one company or
a group of people working together on an open source project.
Skilled programmers expect to see comments in code.
So it's best to start adding these descriptive comments to your programs now.
Writing clear, concise comments in your code is one of the most beneficial habits you can form as a
new programmer.
So when you're deciding whether to write a comment, ask yourself if you had to consider several approaches
before coming up with a reasonable way to make something go.
So if so, write a comment about your solution.
It's much easier to delete extra comments rather ladder than go back and write comments for sparsely
commented program.
So for now I will use comments in examples throughout this course to help explain what sections of code.