Page 117 - Touchpad_Plus_V3.2_Class 6
P. 117
The result of the above program is:
Output
False
True
False
True
False
True
PRECEDENCE OF OPERATORS
Precedence of operators determines the order in which the operators are executed. The operator
precedence in Python is listed in the following table. The highest precedence is at the top.
Operator Name
() Parenthesis
** Exponent
*, /, %, // Multiplication, Division, Modulo, Floor Division
+, – Addition, Subtraction
==, !=, >, <, >=, <= Comparison
=, +=, -=, *=, /=, %=, **=, //= Assignment
and, or, not Logical
SAMPLE PROGRAMS
Program 5: To subtract two numbers entered by the user.
Program5.py
File Edit Format Run Options Window Help
#Program to compute the difference between two numbers entered by the user
a = int (input ("Enter the first number: " ))
b = int (input ("Enter the second number: " ))
sub = a - b
print ("Difference of two numbers is :" , sub)
Introduction to Python 115

