Page 113 - ComputerGenius_V2.1_Class8
P. 113

Running a Python Program                                                   Notes

                 Follow these steps to run a Python program:
                                                                             Shortcut key to run the program is F5.



                                             1  Click on Run in the Menu bar.






                       2  Click on Run
                       Module option.




                 The program will execute and the output will be shown in the Shell window.


















                    Unlike Java and C++, Python does not use brackets to delimit code; but indentation is
                    mandatory with Python.


                 Types of Errors

                 Error  is a term used to describe any concern that arises unexpectedly in a computer ,as a result
                 the computer could not function properly. Computers can encounter two types of errors, either
                 software errors or hardware errors.

                 Hardware error: A hardware error is a malfunction of a hardware component such as CPU, RAM,
                 etc., in a computer system.
                 Software error: Software errors result due to some fault in a computer program.

                 Types of Errors in Python

                 l   KeyboardInterrupt: Raised when the user presses the interrupt key. [Ctrl+C or delete].

                 l   IndentationError: Raised when there is an incorrect indentation in a program.
                 l   ImportError: Raised when the imported file is not found.

                 l   SyntaxError: Raised when syntax is not used properly.

                 l   NameError: Raised when a variable is not found.




                                                                                            Basics of Python   111
   108   109   110   111   112   113   114   115   116   117   118