Variables and Expressions, continued CMSC 201. Expressions Anything on the right hand side of an assignment is an expression. An expression is anything.

Slides:



Advertisements
Similar presentations
CMSC 104, Version 9/011 Arithmetic Operators Topics Arithmetic Operators Operator Precedence Evaluating Arithmetic Expressions In-class Project Incremental.
Advertisements

CS 1 with Robots Variables, Data Types & Math Institute for Personal Robots in Education (IPRE)‏
Estimating Quotients.
Intro to Robots Conditionals and Recursion. Intro to Robots Modulus Two integer division operators - / and %. When dividing an integer by an integer we.
Dividing Monomials Tammy Wallace Varina High. Dividing Monomials The opposite of division is ______________. And when multiplying monomials, the rule.
MATH 2A CHAPTER EIGHT POWERPOINT PRESENTATION
Copyright © Cengage Learning. All rights reserved. 0 Precalculus Review.
Computing with Numbers CSC 161: The Art of Programming Prof. Henry Kautz 9/14/2009.
Section 4.3: Fermat’s Little Theorem Practice HW (not to hand in) From Barr Text p. 284 # 1, 2.
Intermediate Algebra Prerequisite Topics Review Quick review of basic algebra skills that you should have developed before taking this class 18 problems.
Variables and Expressions Order of Operations Real Numbers and the Number Line Objective: To solve problems by using the order of operations.
CC112 Structured Programming Lecture 4 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Factors: Divisibility Rules, Exponents, Prime Factorization and Greatest Common Factor (GCF) Mr. Martin.
Lecture-2 Operators and Conditionals. Variables(again???) Type: Representation of “bits” in memory Variables: Name for a memory object. Starts with letters,
Operators in Python. Arithmetic operators Some operators in Python will look familiar (+, -, *, /) Others are new to you (%, //, **) All of these do work.
Arithmetic Operations. Review function statement input/output comment #include data type variable identifier constant declaration.
Variables and Expressions CMSC 201 Chang (rev )
Variables and Expressions, continued CMSC 201. Expressions Anything on the right hand side of the equals is an expression. Expressions can be anything.
Math With Java The Math Class. First, A Quick Review of Math Operators in Java Primitive Data type in Java that represent numbers: Primitive Data type.
CPS120: Introduction to Computer Science Operations Lecture 9.
Operators Precedence - Operators with the highest precedence will be executed first. Page 54 of the book and Appendix B list C's operator precedence. Parenthesis.
Primitive Data Types. Identifiers What word does it sound like?
Decision Making CMSC 201. Overview Today we will learn about: Boolean expressions Decision making.
Warm-up, 3/28 Compute: 1. 2 x 2 x 2 x 2 = 2. 3 x 3 x 3 = 3. 2 x 2 x 3 x 3 x 3 = 4. 5 x 5 x 2 x 2 = 5. 2 x 2 x 4 =
Visual Basic I Programming
Significant Figure Rules RulesExamples The following are always significant Non zero digits Zeros between non zero digits Zero to the right of a non zero.
Assignment statement: Assigns a value to a variable Variable must appear on the left side, value on the right side of the assignment operator Right side.
Mathematical Calculations in Java Mrs. C. Furman.
Definition Section 4.1: Indefinite Integrals. The process of finding the indefinite integral of f(x) is called integration of f(x) or integrating f(x).
Arithmetic OperatorOperationExample +additionx + y -subtractionx - y *multiplicationx * y /divisionx / y Mathematical FormulaC Expressions b 2 – 4acb *
This will all add up in the end. Assignment operator =Simple Assignment operator Arithmetic Operators +Additive operator – Subtraction operator * Multiplication.
Arithmetic Expressions Addition (+) Subtraction (-) Multiplication (*) Division (/) –Integer –Real Number Mod Operator (%) Same as regular Depends on the.
Doing math In java.
Intro to Algebra Brenda Windsor Math Basic Terms =equal to ≠ not equal to > is greater than
Powers and Laws of Exponents SWBAT write the standard form for numbers that are given in exponential form; write the exponential form for numbers that.
Equations Solving Equations. How does one find a solution? Use Inverse Operations. Addition  Subtraction Multiplication  Division Square  Square.
Introduction to Complex Numbers Adding, Subtracting, Multiplying Complex Numbers.
PYTHON VARIABLES : CHAPTER 2 FROM THINK PYTHON HOW TO THINK LIKE A COMPUTER SCIENTIST.
Data Manipulation Variables, Data Types & Math. Aug Variables A variable is a name (identifier) that points to a value. They are useful to store.
AOIT Introduction to Programming Unit 2, Lesson 6 Arithmetic Operators and Operator Precedence Copyright © 2009–2012 National Academy Foundation. All rights.
Thinking about programming Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Variables and Expressions Order of Operations Real Numbers and the Number Line Objective: To solve problems by using the order of operations.
Dr. Sajib Datta Jan 21,  Declare a variable ◦ int height; [note that no value is still assigned]  Assign a variable a value ◦ height =
Math 094 Section 1.3 Exponents, Order of Operations, and Variable Expressions.
Do Now. Laws of Exponents -Evaluating Exponents MAFS.8.EE.1.1: Know and apply the properties of integer exponents to generate equivalent numerical expressions.
CMSC201 Computer Science I for Majors Lecture 03 – Operators
Chapter 7 Objectives Define basic terms in algebra: integer, number statement, expression, and coefficient Learn the relationships between positive and.
Thinking about programming
ONE STEP EQUATIONS.
Introduction to Programming
ONE STEP EQUATIONS.
CMSC201 Computer Science I for Majors Lecture 03 – Operators
Review # 2 Math 8.
Place Value, Names for Numbers, and Reading Tables
Arithmetic Expressions & Data Conversions
Variables, Data Types & Math
Variables, Data Types & Math
Relations And Functions © 2002 by Shawna Haider.
Relations And Functions.
Variables, Data Types & Math
Arithmetic Operators Topics Arithmetic Operators Operator Precedence
Multiply and divide Expressions
Math-7 NOTES What are Two-Step Equations??
ONE STEP EQUATIONS WHAT?!?!.
ONE STEP EQUATIONS.
Class code for pythonroom.com cchsp2cs
ONE STEP EQUATIONS.
Arithmetic Expressions & Data Conversions
Introduction to Python
Presentation transcript:

Variables and Expressions, continued CMSC 201

Expressions Anything on the right hand side of an assignment is an expression. An expression is anything that yields a value. a = 4 b = 10 * a c = (100 * 4) // # This is a function call, # which we’ll discuss later. d = sin(40)

Operators Some basic operators: OperationPython Operator Addition+ Subtraction- Multiplication* Division/ // Exponentiation** Modulus%

Operators Exponentiation: number ** power So if we want 3 squared, we say: 3 ** 2 If we want 2 cubed, it would be: 2 ** 3

Modulus Modulus: a % b gives “the remainder of a after a is divided by b” 14 % 6 == 2 12 % 2 == 0 10 % 3 == 1

Modulus Why is modulus useful? Tells us if one thing is divisible by another (if you mod a by b and get zero, b is divisible by a) Remainders are useful! Imagine you know the first of a month is a Monday, and you want to know what day the 27 th is. All you need to do is figure out 27 % 7, and that’s how many days past Monday you are.

Integers vs. Floats Data in python remembers what type it is. a = 4 a is an integer. b = 4.4 b is a float. Floats and integers act differently!

Integer vs. Float Division a = 7 b = 3 print(a/b) prints a = 7 b = 3 print(a//b) prints 2

Integers vs. Floats When we divide a float and anything else, the result is a float. However, there is often rounding error. 7.0 / Be careful to never compare two floats after you have done division! What happens if you print this??? print( )

Other Math Functions Other math functions: from math import * FunctionPurpose cos(x), sin(x), tan(x)Trigonometric functions log(x, base)Logarithm of x with given base floor(x)Finds the closest integer less than or equal x ceil(x)Finds the closest integer greater than or equal to x sqrt(x)Finds the square root of x piThe value of pi eThe value of e