Page 78 - IPP-11
P. 78

SOLVED QUESTIONS
                18.  What type of error will be produced when you type:
                    Result = “Python” + 10
                    Name the error and error message.
               Ans.  The error is: TypeError
                    The error message is: Can’t convert ‘int’ object to str implicitly
                19.  What type of error will be produced when you type:
                    while True print(“Hello world”)
               Ans.  The error is: SyntaxError: invalid syntax
                20.  Identify the error in the following Python statement:
                   >>> print("My name is", first_name)
                    Write the corrected statement also.
               Ans.  The above statement is trying to print the value of an undefined variable first_name. The correction is
                   made by defining the variable name before using it, i.e.,
                   >>> first_name = 'Rinku'
                   >>> print("My name is", first_name)


              UNSOLVED QUESTIONS
                36.  Name three runtime errors that occur during Python program execution.

                37.  What is the difference between an error and exception?
                38.  Explain the difference between syntax error and runtime error with examples.
                39.  Which data type will be used to represent the following data values and why?
                   (a)  Number of months in a year     (b)  Resident of Delhi or not
                   (c)  Mobile number                  (d)  Pocket money
                   (e)  Volume of a sphere             (f)  Perimeter of a square
                   (g)  Name of the student            (h)  Address of the student
                40.  What is the error in the following code?

                   z,p = 6
                41.  Find out the error(s) in the following code fragments:
                   (1)  temperature = 90
                       Print temperature
                   (2) a = 30
                       b = a + b
                       print(a And b)
                   (3) a, b, c = 2, 8, 9                                                                          Python Programming Fundamentals (Additions)
                       print(a, b, c)
                       c, b, a + a, b, c
                       print(a ; b ; c)
                   (4) x = 24
                       4 = x
                   (5) Print("X =" X)













                                                                                                              3.9
   73   74   75   76   77   78   79   80   81   82   83