PYTHON PROGRAMMING
PYTHON PROGRAMMING
1 of 4
In the Python Shell
1. Select File then New File to open the Python script editor.
2. Write the statements to be executed.
3. Save the file by selecting File then Save AS option.
4. To execute the code select Run the Run Module or press F5.
5. The output will be visible in the previously open Python Shell.
Keywords/commands in Python
input is used to fetch an input from the user.
print is used to output information on the screen.
VARIABLE IN PROGRAMMING
A variable in a computer program is a named data store than contains a value that may
change during the execution of a program.
A constant in a computer program is a named data store than contains a value that does not
change during the execution of a program.
Variables and constants should be given meaningful names.
Using an undefined variable in a statement causes an error called Name Error.
2 of 4
4. Keywords are not allowed as a variable name eg def, while, for, if etc.
5. Python is case-sensitive, variables in upper case are different to those in lower case.
Declaring variables
Every variable has a data type which defines the format of the variable.
For example x=3.
It means value 3 will be assigned to the integer variable x automatically.
3 of 4
Example 1
Output
Example 2
If you do not use int or float function, the + operator will concatenate two strings.
Output
4 of 4