Comments
Commenting involves placing Human Readable Descriptions inside of computer programs detailing what the Code is doing. This details what certain parts of the code are for, and lets other developers – you included – know what you were up to when you wrote the code. This is a necessary practice, and good developers make heavy use of the comment system. Without it, things can get real confusing, real fast.
In Python we have two methods when commenting, these are the: Consecutive Single-line Comments: Here you simply use a # single-line comment on every line
Multi-line Strings as Comments: Here you use the """ syntax to create a multi line comment.
In [2]: # Here inputs are requested and stored in variables test and num
text = input ("Type anything: ")
num = input ("Enter a number: ")
# Prints in the console the variable as requested
print ("\n You typed in: ", text)
print ("\nThe number you entered is: ", num)
"""
This converts the string into a integer using int() for decimal
format we use the float() function
"""
num type = int(num)
# This would inform you on the type of input you entered
print("\n The Data type for text is : ",type(text))
print("\nThe Data type for num is: ", type(num type))
Out[2]: Type anything:
Enter a number:
You typed in: Hello there!
The number you entered is: 7
The Data type for text is : <class 'str'>
The Data type for num is: <class 'int'>
As seen above we have made use of both types of commenting methods we have in Python. One point to notice is that they don’t appear on the displayed output.