Page 111 - Computer - 6
P. 111
Mind Fog ERROR
Python executes a script only if it is error-free. If there are errors in the script, Python informs you about
them in the IDLE window.
To close a script: 1
1. On the Menu bar, click the File menu.
The File menu opens. Time Saver
2. Select the Close Window option.
The Editor window is closed. The Close a script: Alt + F4
cursor blinks at the Python prompt
in the Shell. 2
To exit Python IDLE: 1
1. On the Menu bar, click the File menu.
The File menu opens.
2. Select the Exit IDLE option. Time Saver
The Python IDLE window closes. Close Python IDLE: Ctrl + Q
2
UNDERSTANDING VARIABLES
Variables are named locations in the memory of a computer where data is stored temporarily. The data
stored in the variables can be manipulated during the execution of a program. Interactive programs are
written using variables containing different types of data, such as numbers, text, and Boolean values
(True/False).
Every variable in a script has a name by which it is referred to during the execution of the script.
In Python, there are several rules that should be followed while naming variables:
1. Variable names should be meaningful and related to the purpose of the variable.
2. Variable names can contain alphabets, digits, and the underscore symbol ( _ ).
3. Variable names must start with an alphabet or the underscore symbol. They cannot start with a
digit.
4. You cannot use reserved words or keywords in Python as a variable name. Some examples of
Python keywords are print, input, else, while, and if.
5. Variable names in Python are case-sensitive. Thus, Name and name are treated as different variables.
The following table displays examples of valid and invalid variable names in Python.
Valid Variable Names Invalid Variable Names
Name 5Books
Data123 Name@school
My_Age My Age
Book1_toread print
109