Page 75 - ModularV1.1 _c8_flipbook
P. 75
Clickipedia
Operator Precedence :- P E D M A S rule is Parenthesis, Exponential, Division, Multiplication,
Addition and Subtraction.
Logical Operators
They are used to combine multiple conditions and evaluate them. They return a Boolean value
‘True’ or ‘False’ as result.
Operator Description
& (AND) Returns ‘true’ value if all the given conditions are true.
| (OR) Returns ‘true’ value if any one of the given conditions is true.
COMMENTS IN PYTHON
Comments are the text written inside the code for better understanding of the code. A hash
character (#) is written at the beginning of the comment. Comments are not a part of the code
and are ignored by the Python interpreter.
For example, #Program on simple calculator
This line will not be read by the Python interpreter but it is giving information about the program
to the reader.
THE INPUT( ) STATEMENT
This statement is used to take input from the user during the execution of the program. The
input statement acts as a message communicator between the user and the computer.
The general syntax is :
Syntax input (“prompt”), here prompt is a message for the user related to the code.
Example X = input ("What is your name?" )
In this example, the input statement will use the prompt “What is your name?” to get the input
from user and assign it to the variable X.
The value taken from the input statement is a string value. To convert this value into an integer
or float for further calculation, use the following functions:
Function Description Example
Int ( ) The int ( ) function converts a float or int (x) converts variable x into an
string variable into int data type integer
float ( ) The float ( ) function converts a string or float (x) converts variable X into a
int variable into a float data type floating point number.
THE PRINT( ) STATEMENT
The print ( ) statement is used to print the output of a program on the screen. The general syntax is :
Syntax print (“message” , variable _ name)
Example print ("Area of the square is", area)
Introduction to Python 73

