Comments

Try to comment your code so as not to be hard to decipher. This will help your work mates and you will get a lot of benefits of it. Coworkers will like your code without even knowing why.

You got the idea.

To comment a line of code write # then start commenting.

a = 5 # our variable was initialized to ... because ...

To comment a variable you can also write a string on the next line.

t = 1000
"the time was set to 1 second "
print(t) # 1000

To write a comment on more lines, you can write a multi-line string.

t = 1000
"""the time was 
	set to 1 second """
print(t) # 1000

Using just a doublequote instead of three doublequotes will give you an error.

The same technique applies to functions:

def myfun():
	"""
	This is a comment example.
	It is written on next line to the function definition.
	It should be indented.
	"""
	do_something()
	return 1

When you comment functions, try writing something relevant, like the meaning of its parameters.

In order to avoid writing long lines of comments, you can call your variables and function names in a meaningful way. For example:

def month_savings(month_income, expenses):
	return month_income - expenses
	
june_savings = month_savings(10000,4000)
print(june_savings)

You can understand the code without even knowing programming. There is no comment needed.

Give shorter names to the variables which are most used and longer names to the ones that are less frequently used.

Don’t overdo it! Too much commenting can be annoying.