Page 139 - TP_Prime_v2.2_Class_6
P. 139

21 st   #Critical Thinking
                      Warm                                                                       Century
                                                                                                  Skills
                      Up!         State whether these statements are True or False.

                                  1.  The print( ) function is used to print hard copy of the Python code.
                                  2.  “\n” separate is used to create a new file in Python.

                                  3.  The type( ) function is used to find data type of the values.                          INTRODUCTION TO PYTHON






                   Comments in Python

                 Comments in Python can be used to explain parts of the code. It can also be used to hide

                 the code as well. Comments enable us to understand the way a program works. In Python,
                 any statement starting with # symbol is known as a comment. Python does not execute
                 comments. Comments are not a part of the program, but they do enhance the interactivity                  137

                 of the program and make it readable. Python supports two types of comments: Single-line
                 comment and Multiline comment.


                   Single Line Comment

                 In case, a user wants to specify a single-line comment, then comment must start with the
                 symbol #. Example:

                                  Program:                            Output:

                                  # printing a string                 Hello World
                                  print("Hello world")


                   Multiple-line Comment


                 Python does not have a syntax for multiline comments. To add a multiple line comment, you
                 could insert a # for each line. Example:

                                  Program:                            Output:

                                  # printing a string                 Hello World
                                  #print five names                   Rachna
                                  print("Hello World")                Sambhav
                                  print("Rachna")                     Akshat

                                  print("Sambhav")                    Tushar
                                  print("Akshat")
                                  print("Tushar")
   134   135   136   137   138   139   140   141   142   143   144