Page 114 - trackpad v5.1 class 8 flipbook
P. 114

You will get the following output:

                      Output
                   Hello Orange! How do you do?




                  Program 2: To add two numbers using user-defined function

                      Program2.py
                   File  Edit  Format    Run   Options   Window    Help

                   #Program that demonstrate to create a user-defined function
                   def add (a, b):
                       c = a+b
                       print("The sum of both the numbers is", c)
                   add (12, 16)




                  You will get the following output:

                      Output

                   The sum of both the numbers is 28






                       PURE        Approximately, 1.4% of all websites on the Internet use Python as a server-side
                       FACT        programming language.







                            STRING

                  A sequence of characters which is enclosed or surrounded by single (' '), double (" "), or Triple
                  ('''  ''') quotes is known as a string. The sequence may include a letter, number, special characters
                  or a backslash. Python treats single quotes as double quotes.


                  Program 3: To print a string

                       Program3.py
                    File  Edit  Format  Run    Options  Window    Help

                    str = "This is Shweta's pen."                              Output
                    print(str)                                               This is Shweta's pen.










                   112  Pro (V5.1)-VIII
   109   110   111   112   113   114   115   116   117   118   119