Page 84 - Code & Click - 6
P. 84
To close a script: 1
1. On the Menu bar, click the File menu.
2. Select the Close Window option. Time Saver
The Editor window is closed. Close a script: Alt + F4
The cursor blinks at the Python
prompt in the Shell.
1
To exit Python IDLE: 2
1. On the Menu bar, click the File menu.
2. Select the Exit IDLE option. Time Saver
The Python IDLE window closes. Close Python IDLE: Ctrl + Q
UNDERSTANDING VARIABLES 2
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 can contain alphabets, digits, and the underscore symbol ( _ ).
2. Variable names must start with an alphabet or the underscore symbol. They cannot start with a
digit.
3. 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.
4. 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
Assigning Values to Variables
Every variable must have a value. The value stored in a variable is processed during the program’s
execution. The Assignment operator ‘ = ’ (equal to) is used to assign a value to a variable.
For example, to assign the value 10 to variable Age, the command is: Age = 10
INPUT AND OUTPUT OPERATIONS IN PYTHON
Python provides two in-built functions for performing input and output operations. Input operations
involve accepting data values from the user and storing them in a variable. Output operations involve
displaying messages or values of variables and expressions on the screen.
82