WEBVTT

00:00.800 --> 00:05.480
Comments are extremely useful feature in most programming languages.

00:05.540 --> 00:10.100
Everything you have written in your program so far is Python code.

00:10.520 --> 00:16.610
As your programs become longer and more complicated, you should add nodes.

00:17.400 --> 00:22.810
Within your programs that describe your overall approach to the problems you're solving?

00:22.830 --> 00:29.460
So a comment allows you to write notes in your spoken language within your programs.

00:29.460 --> 00:34.230
So how do how do you write comments?

00:34.230 --> 00:38.940
So in Python, the hash mark here.

00:38.970 --> 00:41.100
The hash mark.

00:42.370 --> 00:44.590
Let's actually let's use a different color.

00:44.620 --> 00:45.160
Yes.

00:45.520 --> 00:47.590
So the hash mark.

00:51.950 --> 00:53.630
Indicates a comment.

00:53.960 --> 01:00.800
Anything following a hash mark in your code is ignored by the python interpreter here.

01:00.800 --> 01:02.240
As you can see, we got an error here.

01:02.240 --> 01:06.410
That's because in reality my value doesn't exist.

01:06.410 --> 01:08.780
If we comment this, it will not compile.

01:09.020 --> 01:09.950
So.

01:11.000 --> 01:13.240
Let's do something here.

01:13.250 --> 01:14.270
So.

01:15.050 --> 01:15.890
Hello.

01:16.310 --> 01:18.620
Oxley students here.

01:18.710 --> 01:19.340
So.

01:19.340 --> 01:20.540
And print.

01:22.360 --> 01:26.740
Hello Python people and let's run it.

01:26.740 --> 01:29.740
And as you can see, we are seeing only our.

01:30.580 --> 01:36.910
Um, print function and Python ignores the first line and executes the third line.

01:37.620 --> 01:41.010
So what kinds of comments should we should you write?

01:41.040 --> 01:47.400
So the main reason to write comments is to explain what your code is supposed to do and how you are

01:47.400 --> 01:48.420
making it work.

01:48.450 --> 01:54.780
So when you are in the middle of working on a project, you understand how all of the pieces fit together.

01:54.780 --> 02:01.920
But when you return to a project after some time away, you will likely have forgotten some of the details,

02:01.930 --> 02:02.360
right?

02:02.370 --> 02:08.370
So you can always tidy your code for a while and figure out how segments you were supposed to work.

02:08.370 --> 02:15.090
But writing good comments can save you time by summarizing your overall approach clearly.

02:15.120 --> 02:20.940
If you want to become a professional programmer or elaborate with other programmers, you should write

02:20.940 --> 02:22.440
meaningful comments.

02:22.470 --> 02:29.520
Today, most software is written collaboratively, whether by a group of employees at one company or

02:29.520 --> 02:34.200
a group of people working together on an open source project.

02:34.960 --> 02:38.650
Skilled programmers expect to see comments in code.

02:38.650 --> 02:44.410
So it's best to start adding these descriptive comments to your programs now.

02:44.440 --> 02:51.430
Writing clear, concise comments in your code is one of the most beneficial habits you can form as a

02:51.430 --> 02:52.660
new programmer.

02:52.690 --> 03:00.430
So when you're deciding whether to write a comment, ask yourself if you had to consider several approaches

03:00.430 --> 03:04.240
before coming up with a reasonable way to make something go.

03:04.240 --> 03:07.150
So if so, write a comment about your solution.

03:07.150 --> 03:15.700
It's much easier to delete extra comments rather ladder than go back and write comments for sparsely

03:15.700 --> 03:16.990
commented program.

03:16.990 --> 03:27.070
So for now I will use comments in examples throughout this course to help explain what sections of code.
