Page 107 - Computer - 8
P. 107

Lab Activity 3                                                                         Experiential Learning
           To create a user-defined function that takes arguments, returns a value and call it.

           1. Type the code as shown in the image in the Python Editor.





















           2. Press the F5 key to execute the code. Sample output of the program is given below.




















                   Try This
                                                                                                       Logical Thinking
             Identify the error in the code segment given below and write the correct code:
                    Def my_function(a, b, c)
                           print(“The sum of numbers is : a + b + c”)
                    myfunction(10, 20, 30)


          WORKING WITH STRINGS
          A String in Python is a sequence of characters (digits, alphabets, spaces, or symbols) enclosed within
          single quotes (‘ ’) or double quotes (“ ”). Examples of strings in Python are “Python”, ‘P’, “1234”, and
          “I Love Programming”.



          Mind Fog       ERROR


             Numbers that are enclosed within double quotes are treated as strings, and mathematical operations are
             not permitted on them.



                                                                                                             105
   102   103   104   105   106   107   108   109   110   111   112