Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 95 - 2607_Trackpad_Pro_5.1_flipbook_C7
P. 95

    RUN-TIME ERRORS
                      Run-time errors in Python occur while the program is executing, causing it to crash or behave

                      unexpectedly. These errors arise due to issues such  as  invalid  operations,  unavailable
                      resources, or invalid inputs. For example:

                          IDLE Shell 3.10.5
                       File  Edit  Format    Run   Options   Window    Help

                        >>> a=10
                        >>> b=0
                                                                                      Invalid Logic
                        >>> c=a/b
                                                                                      t
                        Traceback (most recent call last):
                            File "<pyshell#5>", line 1, in <module>
                             c=a/b
                            ZeroDivisionError: division by zero

                                SOME MORE PROGRAMS

                      Program 1: Write a program to take distance in Kilometres and convert it into Meters.

                               #Take distance in Kilometres from the user
                               km = float (input('Enter distance in kilometres'))
                               m = km * 1000
                               print ("Distance in metre is ", m)

                      Program 2: Write a program to take the length and width of a rectangle as input and calculate its area.

                             Hashtag

                           #Operator: A symbol that is used to perform some specific operations
                           #Keywords: The reserved words which are used for some specific purposes

                       94   Premium Edition-VII

| 90 91 92 93 94 95 96 97 98 99 100 |