0% found this document useful (0 votes)
41 views15 pages

Part 2 Arithmetic Operators

Arithmetic operators allow for mathematical operations in programming languages. They include addition, subtraction, multiplication, division, exponents, integer division, remainders, and parentheses to group operations. Different operators have different priority levels which determine the order that operations are performed in an expression from left to right. The document provides examples of arithmetic operators in Python and explains how to convert expressions between mathematical and programming notation.

Uploaded by

El Yisus God
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views15 pages

Part 2 Arithmetic Operators

Arithmetic operators allow for mathematical operations in programming languages. They include addition, subtraction, multiplication, division, exponents, integer division, remainders, and parentheses to group operations. Different operators have different priority levels which determine the order that operations are performed in an expression from left to right. The document provides examples of arithmetic operators in Python and explains how to convert expressions between mathematical and programming notation.

Uploaded by

El Yisus God
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Arithmetic

operators
Module 2 / Operators and Decisions
Arithmetic Operators

Arithmetic operators

+ - * /
addition subtraction multiplication division

** // %
integer
exponent remainder
division
Arithmetic Operators

Arithmetic operators

3+2=5 7-3=4
addition subtraction

2*4=8 6/3=2
multiplication division

Some examples
OperadoresOperators
Arithmetic Aritméticos

Exponent

3 ** 2 = 9 2 ** 3 = 8
exponent exponent

32 = 9 23 = 8
It is like this in math It is like this in math
Arithmetic Operators

Integer Division

5 / 2 = 2.5 5 // 2 = 2
Regular division Integer division

17 / 6 = 2.833.. 17 // 6 = 2
Regular division Integer division

The integer division has no decimals.


It just shows the integer, without decimals.
Arithmetic Operators

Remainder or Modulus

33 % 6 = 3
Remainder

11 % 2 = 1
Remainder

The modulus operator returns the remainder of an integer division


Arithmetic Operators

Remainder or Modulus

100 % 8 = 4 25 % 5 = 0
Remainder Remainder

The modulus operator returns the remainder of a division


Arithmetic Operators

Parentheses

()
Parentheses

(3+2) * 2 = 10
Parentheses use

The parentheses are used only to group values or operations.


Unlike math or physics, parentheses do not represent multiplication.
Arithmetic Operators

Priority order
They are first priority operations. Operations within parentheses are evaluated

() first. If nested parentheses are found, (one inside the other), the expressions
in the innermost parentheses are evaluated first. If multiple parentheses are
found on the same level, they are evaluated from left to right.

* / // % They are second priority operations. If there are several of them in


the expression, they are evaluated from left to right.

+ - They are third priority operations. If there are several of them


in the expression, they are evaluated from left to right.
Arithmetic Operators

Exercises. Solve individually on a sheet of paper

( 5 + 4 ) + ( 3 * 2) ( 25 /5 ) ** 2

8 + 3 * 11 - 2 ( 2 ** 2 ) ** 2

8%3+1 ( 25 % 3 ) * ( 5 % 3 )

22 // 10 * 3 ( 3.5 + 3.2 + 3.3 ) * 2

15 / 3 * 2 ( 51 % 5 ) * 5 // 2 + 4

12.5 + 12.5 + 1 5 / 2 + 10 // 3 / 3
Arithmetic Operators

Converting Expressions
The parentheses are used only to group values or operations. Unlike math or physics,
parentheses do not represent multiplication.

(4 X 5)2
--------------------- (4 * 5)**2 / ( ( 2 * 3 )**3 + ( 5 * 2 ) * (3 * 3)**2 )
( 2 X 3 )3 + ( 5 X 2 )(3 X 3)2

Mathematics Python
Arithmetic Operators

Converting Expressions

A= P*(1+r/n)**(n*t) A= P*(1+r/n)**(n*t)

Finance Python
Arithmetic Operators

Calculating Areas

Area of a Triangle

Python
Arithmetic Operators

Now practice calculating the area of a pentagon


S09. Arithmetic Operators
CREDITS
Ana Isabel Ramos Elizondo Laura Guadalupe Molina Salgado
aire@tec.mx laurag.molina@tec.mx

Francisco J. Guerra Treviño Dan Omar Marrón Muñoz


paco.war@tec.mx dmarron@tec.mx

Federico Enrique Berndt M.


federico.berndt@tec.mx

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy