A comment is a message to someone reading your program. Comments are often used to describe what a section of code does or how it works, especially with tricky sections of code. Comments
have no effect on your program i.e it will not run while running the codes. there are two type of comment
this is comment that is not more than a line. For a single-line comment, use the
# a slightly sneaky way to write condition statement x=5 print('x is greater than 3') if x>3 else print('x is not greater than 3')
x is greater than 3
score=60 if score>=50: #check if score is greater than 50 print('pass') #print 'psdd' if true else: #if it is not greater than 50 print('fail')#print 'fail'
this is used for comments that span several lines, you can use triple quotes.
""" Program name: Hello world Author: Maxwizard Date: 27/12/2020 """ print('Hello world')
One nice use for the triple quotes is to comment out parts of your code. sometimes you will want to
modify your program but don’t want to delete your old code in case your changes don’t work. so the best way is to just comment out the old codes so that it is still there if you need it, and it will be ignored when
your new program is run.
''' print('this is my old codes') print('this and the first line are not going to execute.') ''' print('This is my new codes it will execute')
This is my new codes it will execute
''' x='hello' y='myfriend' print(x+y) ''' print('Hello mate!')