

Arithmetic Operators
Presentation
•
Computers
•
Vocational training
•
Practice Problem
•
Medium
Sakxam Shrestha
Used 4+ times
FREE Resource
19 Slides • 2 Questions
1
Arithmetic Operators
American Baptist College
2
Review: Data Types
What are they?
Classification for values
Why are they important?
How to use, change, combine each type
Exampl
integer, float, string, boolean
3
Review: Data Types
Data Type
Definition
Value Examples
integer (int)
number without a decimal point
5, -40, 0, 13382
float
number with a decimal point
3.14, 2.0, -9.5
string (str)
sequence of characters surrounded by quotes ‘abc’, “Hi!”, ‘3.14’
boolean (bool) True or False
True, False
4
Arithmetic Operators
5
Key Terms
operator: symbol performing specific computation on set of
values
expression: combination of operators and values evaluating
to single value
6
Evaluating expressions
2+4
operator
operands
expression
7
Arithmetic Operators
+ Add
-Subtract
* Multiply
/ Divide
**Exponent
8
If any operand is float, evaluated value is float
1 + 2.0 => 3.0 (not 3)
If all operands are integers, evaluated value is integer
4 * 3 => 12 (not 12.0)
EXCEPT DIVIDE /- evaluated value is always float
12 / 4 => 3.0
12.0 / 4.0 => 3.0
12.0 / 4 => 3.0
Arithmetic Operators: Floats, Integers
9
Multiple Choice
What will be the result of the following operation?
5 + 7.0
12
12.0
12.00
Error
10
+ Add
"And" + "rea" => "Andrea"
Arithmetic Operators: Strings
Adding strings together is called
concatenation.
* Multiply
"hello" * 2 => "hellohello"
Note: string multiplication only exists in Python
11
// divides two numbers and rounds result down to next whole number
Examples:
5 // 2 evaluates to 2
5.0 // 2.0 evaluates to 2.0
42 // 10 evaluates to 4
9 // 9 evaluates to 1
9.0 // 9.0 evaluates to 1.0
Operator: Floor Division
12
Operator: Modulo
% computes remainder after division
Examples:
5 % 2 evaluates to 1
5.0 % 2.0 evaluates to 1.0
24 % 10 evaluates to 4
9 % 9 evaluates to 0
9.0 % 9.0 evaluates to 0.0
13
Order of Operations
Parentheses
Exponents
Multiplication
Division
Addition
Subtraction
MD and AS have the same precedence, go left to right
MD, //, and % have the same precedence, go left to right
14
Multiple Choice
What is the result of the following expression?
2 + 3 * 4
14
20
24
9
15
PEMDAS
2 + 1 * 5 - 6 / 2
3 + (1 + 4) * 2
'h' + 'i' * 3
2 + 5 - 3.0
=
4.0
=3 + 5 * 2
= 13
= 'h' + 'iii' =' hiii'
16
What happens?
"5" + 5
TypeError: cannot concatenate 'str' and 'int' obj
How to fix this?
"5" + str(5)
17
Functions
function: performs specific action
on a set of values
Takes inputs
Performs task on inputs
Optionally, gives output
Inputs and outputs of a function are values.
18
Built-in functions
type()determines data type of input value
int()converts input value to an integer
float()converts input value to a float
str()converts input value to a string
bool()converts input value to a boolean
19
Type Conversions
Convert numbers to other type by using int() and float() functions
int(5)
5
int(3.42)
3
float(5)
5.0
float(5.6)
5.6
str(5)
"5"
str(int(2.8))
"2"
Does calling int() with an int or float() with a float change the value?
20
Review: Expressions, Functions
Values and operators make up expressions
Computers evaluate expressions down to a single value
2+4
operator
operands (values)
expression
Functions perform an action on input value(s) to compute a result
type() int() float() str() bool()
21
If any operand is float, evaluated value is float
If all operands are integers, evaluated value is integer
EXCEPT DIVIDE /- evaluated value is always float
Review: Arithmetic Operators
// Floor Division
Round down to nearest whole number
% Modulo (mod)
Remainder
PEMDAS
Order of operations
+ Add
-Subtract
* Multiply
/ Divide
**Exponent
Arithmetic Operators
American Baptist College
Show answer
Auto Play
Slide 1 / 21
SLIDE
Similar Resources on Wayground
18 questions
Never Tell A Lie
Presentation
•
KG
14 questions
Repaso UNIT 2 - 1º ESO
Presentation
•
KG
13 questions
Multiply by 10
Presentation
•
Professional Development
14 questions
History and More on El Salvador
Presentation
•
KG - Professional Dev...
18 questions
Perfect Squares Recap
Presentation
•
6th Grade
15 questions
Learn DAX Basics
Presentation
•
Professional Development
18 questions
STAAR Vocabulary Review
Presentation
•
6th Grade
16 questions
ເຄມີ ບົດທີີ1
Presentation
•
KG
Popular Resources on Wayground
5 questions
A Home on the Shore
Quiz
•
3rd Grade
28 questions
US History Regents Review
Quiz
•
11th Grade
6 questions
A Horse Tale
Quiz
•
3rd Grade
20 questions
Math Review
Quiz
•
3rd Grade
10 questions
Juneteenth History and Significance
Interactive video
•
5th - 8th Grade
20 questions
Dividing Fractions
Quiz
•
5th Grade
55 questions
A Long Walk to Water Final Review
Quiz
•
6th - 8th Grade
10 questions
Equation Word Problems
Quiz
•
7th Grade