Page 20 - tp_Modula_v2.0
P. 20

Boolean

                  Boolean is a data type with two built in values: True or False. They are used for logical evaluation.
                  A True statement returns value 1 while a False statement returns value 0.


                      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 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")

                  However, the text written inside triple quotes (''' or ''"") is also considered as comment. You can
                  use the triple quotes to write multiline comments. For example:

                                   '''This is                          """This is

                                      Multiline             OR            Multiline
                                      Comment'''                          Comment"""



                   18     Touchpad MODULAR (Version 2.0)
   15   16   17   18   19   20   21   22   23   24   25