Printing And Comments In Python

Hi there. This short page goes over printing and comments in Python.

Source: https://www.onlinebooksreview.com/uploads/blog_images/2017/08/01_python.png

 


Python’s print() Function

In Python, you can display text with the use of Python’s print() function. If you want to display “Hello World” in Python, you need the code:

The above line of code in Python will display:

 

Other examples of the print() function include:

which produce


Comments In Python

It is good practice to include comments with code as friendly reminders. You may revisit code in a few days, months or even years. Comments help refresh the memory and gives the reader a better idea what is going on in the code.

The pound or hashtag symbol # is used in the beginning of a line for a single line comment.

Instead of using the # symbol multiple times for multi line comments, you can use three of the double quotes together.

 


References

  • References: Starting Out With Python – Second Edition By Tony Gaddis
  • https://stackoverflow.com/questions/7696924/way-to-create-multiline-comments-in-python

Leave a Reply