L05 - Expressions
L05 - Expressions
Branch - CSE
Python Programming
Lecture – 5
Expressions
By
• Output: 16.3
Arithmetic Expressions
• An arithmetic expression is a combination of numeric values, operators, and sometimes
parenthesis. The result of this type of expression is also a numeric value. The operators
used in these expressions are arithmetic operators like addition, subtraction, etc. Here
are some operators in Python:
Operator
Syntax Functioning
s
+ x+y Addition
- x–y Subtraction
* x*y Multiplication
/ x/y Division
// x // y Floor (Integer) Division
% x%y Remainder
** x ** y Exponentiation
3333333333333335
Arithmetic Expressions
• Output:
52
28
480
3.3333333333333335
Integer Expressions
• There are the kind of expressions that produce only integer results after all computations
and type conversions.
• Output: 25
Floating point Expressions
• These are the kind of expressions which produce floating point numbers as result after all
computations and type conversions.
• Output: 2.6
Relational Expressions
• In these types of expressions, arithmetic expressions are written on both sides of
relational operator (>, <, >=, <=). Those arithmetic expressions are evaluated first, and
then compared as per relational operator and produce a Boolean output in the end.
These expressions are also called Boolean expressions.
• Output: True
Logical Expressions
• These are kinds of expressions that result in either True or False. It basically specifies one
or more conditions. For example, (10 == 9) is a condition if 10 is equal to 9. As we know it
is not correct, so it will return False. Studying logical expressions, we also come across
some logical operators which can be seen in logical expressions most often. Here are
some logical operators in Python: