Application of ICT - Lecture 11
Application of ICT - Lecture 11
Naming Conventions
Comments
Multi-line comment
Value and
type
Assignment: =
Arithmetic: +, - , *,
**, / , // , %
Relational or comparison:
==, > , < , >= , <= , !=
Logical : and, or , not
Order of Operation
Multiple operators in an
expression evaluates on
rule of precedence.
PEMDAS: Parentheses,
Exponent, Multiplication,
Division, Add, Subtraction
Operators with same
precedence are evaluated
from Left to Right
Arithmetic Expression
Arithmetic Expression
Practice:
1. result = 3 + 2 * (5 ** 2 - 3
* 2) / 4 – 6
2. result = (3 + 2 * (6 - 4)) **
2 - 10 / 2
3. result = (5 - 8) ** 2 + 6 *
3 - (12 / 4)
Arithmetic Expression
Answer:
1. result = 3 + 2 * (5 ** 2 - 3
* 2) / 4 – 6 =6.5
2. result = (3 + 2 * (6 - 4)) **
2 - 10 / 2 =44
3. result = (5 - 8) ** 2 + 6 *
3 - (12 / 4) =24
Math Functions
Math Functions
Obtain information
from user
x= input () #By default
takes string
as input
X= int(input())
#typecasting
User Input
Eval Function