Page 422 - ComputerScience_Class_11
P. 422

Output

                  Python is easy to learn
                  This program runs in script mode





                  12.7 PYTHON CHARACTER SET
              A programming language character set is the complete set of symbols and characters that can be used to create
              programs. It generally consists of capital and small letters, digits, special symbols such as +, –, *, /, [ ] and whitespace
              characters like space, tab and newline. The different types of symbols in the Python character set are listed below:
                            Letters                     a-z, A-Z

                            Digit                       0-9
                            Special symbols             ~ ! @ # $ % ^ & * () + = - {} [] < > ? | : “ ; ‘ ? , . /
                            White spaces                Blank space, Tab(\t), Carriage return (\r), newline(\n)


                  12.8 COMMENTS IN PYTHON
              Comments are lines in a Python program that are written to explain the code. They are written for programmer to read
              so that the program can be understood more clearly. The Python interpreter ignores comments, so they do not affect
              how the program runs. Comments are useful for describing what a piece of code does, making the program easier to
              read and maintain.

              12.8.1 Types of Comments
              Here are the types of comments in Python:
              1.  Single-line Comment: A single-line comment in Python is used to explain a line of code or give short information
                 about the program. It starts with the hash symbol (#).

                Example: x = 10 # This is a single-line comment
              2.  Multi-line Comment: A multi-line comment in Python is used to explain multiple lines of code or to write a detailed
                 description of a program. Python does not have a separate symbol for multi-line comments. Triple-quoted strings
                 are commonly used as multi-line comments when they are not assigned to a variable.
                Symbols used in multi-line comments are:
                •  ''' (triple single quotes)
                •  """ (triple double quotes)
              Anything written inside these quotes is ignored during execution when used as a comment. For example,
                   Program.py

                File  Edit  Format   Run   Options   Window    Help

                  """
                  This program
                  adds two numbers
                  and displays the result
                  """

                  a= 10
                  b= 20
                  print(a + b)





                  420  Touchpad Computer Science (Ver. 3.0)-XI
   417   418   419   420   421   422   423   424   425   426   427