2. Operators
• Attribution: (=) example x=5 in this case we give x the value 5
• Summation: (+) example x=5 y=6 z=x+y in this case z equal to 11
• Subtraction: (-) example x=5 y=6 z=y-x in this case z equal to 1
• Multiplication: (*) example x=5 y=6 z=x*7 in this case z equal to 31
• Division: (/) example x=5 y=25 z=y/x in this case z equal to 5.0
• Mod: (%) example x=5 y=25 z=y%x in this case z equal to 0
3. Operators Result
• In all programming languages if we division int/int like 5/5 the result will be
of type int (1)
• In python it’s deference a little.
• Rule: any division result in python it gave the type (float)
• So in python when we put (5/5) the result will be 1.0 in float data type.
4. Math operator
• The operator (x+=5) x=x+5
• The operator (x-=5) x=x-5
• The operator (x*=5) x=x*5
• The operator (x/=5) x=x/5
5. Logical operators
• Grater than (<)
• Less than (>)
• Equal (==)
• Grate than or equal (<=)
• Less than or equal (>=)
• No equal (!=)
6. Logical Operators
• In python we can us the keywords (in, not in).
• To get a logical result: like the following example:
x=5
x not in range (1,5)
• Result is true because 5 in range [1 2 3 4 5]
• So the range function give me a series of number
7. Logical Operators
• In python we can us the keywords (in, not in).
• To get a logical result: like the following example:
x=5
x in range (1,5)
• Result is false because 5 in range [1 2 3 4 5]
9. Logical Operators
• We can use the keywords (and – or) to get a logical operators
• Example: 5<10 and 5>3
result will be (True)
• Example: 5<10 or 5<3
result will be (True)