Thinking about programming

Slides:



Advertisements
Similar presentations
Types and Arithmetic Operators
Advertisements

Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
Python Programming Chapter 2: Variables, expressions, and statements Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Exponent Rules – Day 1 Zero and Negative Exponents.
RATIONAL EXPONENTS Assignments Assignments Basic terminology
Introduction to Python
Variables and Exponents
Georgia Institute of Technology Introduction to Java, and DrJava Barb Ericson Georgia Institute of Technology Aug 2005.
PYTHON. Python is a high-level, interpreted, interactive and object- oriented scripting language. Python was designed to be highly readable which uses.
Properties of Exponents
Section 1Chapter 5. 1 Copyright © 2012, 2008, 2004 Pearson Education, Inc. Objectives Integer Exponents and Scientific Notation Use the product.
Week 4. Due for this week…  Homework 4 (on MyMathLab – via the Materials Link)  Monday night at 6pm.  Prepare for the final (available tonight 10pm.
4-1 6 th grade math Exponents. Objective To write and evaluate exponential expressions Why? To prepare you for higher learning in math and science. To.
Chapter 3.  Traditionally, programming languages have assigned different types of data for different types of numbers.  In many languages, there may.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Whole Numbers Section 3.3 Multiplication and Division of Whole Numbers
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Input, Output, and Processing
Exponents An exponent is the number of times the base is multiplied by itself. Example 27 can also be written as 3 This means 3 X 3 X 3.
Exponents & Scientific Notation MATH 102 Contemporary Math S. Rook.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Holt Algebra Properties of Exponents In an expression of the form a n, a is the base, n is the exponent, and the quantity a n is called a power.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Objective The student will be able to: express numbers in scientific and decimal notation. Designed by Skip Tyler, Varina High School.
Scientific Notation Helping us write really tiny or really big numbers.
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
PYTHON VARIABLES : CHAPTER 2 FROM THINK PYTHON HOW TO THINK LIKE A COMPUTER SCIENTIST.
Thinking about programming Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Exponents. 1. Relate and apply the concept of exponents (incl. zero). 2. Perform calculations following proper order of operations. 3. Applying laws of.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
+Addition – like terms -all variables and exponents must match. – add coefficients.
Math, Data Types. Python Math Operations OperationOperator Addition + Subtraction – Multiplication * Division (floating point) / Division (integer) //
CS 100 Introduction to Computing Seminar September 12/14, 2016.
10.7 Operations with Scientific Notation
Thinking about programming
Math operations 9/19/16.
Topics Designing a Program Input, Processing, and Output
A Playful Introduction to Programming by Jason R. Briggs
Introduction to Python
Lecture 4: Expressions and Variables
Presented By S.Yamuna AP/IT
Variables, Expressions, and IO
Objective The student will be able to:
Identifying the Parts of an Expression
SCIENTIFIC NOTATION.
Number and String Operations
Thinking about programming
Introduction to Java, and DrJava part 1
Learning Outcomes –Lesson 4
T. Jumana Abu Shmais – AOU - Riyadh
Unit 2 (8.EE.1) Vocabulary.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
Introduction to Java, and DrJava
Core Objects, Variables, Input, and Output
Objective The student will be able to:
Topics Designing a Program Input, Processing, and Output
Lecture 4: Expressions and Variables
Topics Designing a Program Input, Processing, and Output
Objective The student will be able to:
Beginning Python Programming
Winter 2019 CISC101 4/28/2019 CISC101 Reminders
Introduction to Java, and DrJava
Introduction to Java, and DrJava part 1
Objective The student will be able to:
Translating Words into Math
Objective The student will be able to:
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Presentation transcript:

Thinking about programming Intro to Computer Science CS1510 Dr. Sarah Diesburg

A geek joke

Homework Assignment 1 is Avaliable Linked on homepage Similar problems to yesterday’s lab Submit code on eLearning Print out code, hand in to me at beginning of class on next Wednesday

Questions about the lab?

General comments about the lab Make sure you are answering the question asked and answering them completely/accurately Decimal points When I ask you to predict I mean it. I won’t mark you off for being wrong so don’t fake your “prediction” Try to be as clear as possible in your written answers Start bringing your textbooks to lab

General comments about the lab How many base mathematical operators did we study in lab yesterday? Which one was the most confusing to you?

Operators addition : + subtraction: - multiplication: * division quotient: / Integer quotient: // remainder: % exponentiation: ** (do not use ^)

Ways we can use Python to help Interpreter Using numerical literals Using variables and formulas Try things in here! Scripting To write and save code into programs

Literals Literal is a programming notation for a fixed value. For example, 123 is a fixed value, an integer it would be “weird” if the symbol 123’s value could change to be 3.14!

Number literals By default, IDLE assumes that anything without a decimal is an integer. > 2 2 > -5 -5 By default, IDLE assumes that anything with a decimal is a floating point number. > 3.5 3.5 > -4.0 -4.0

Operator Order The default evaluation order is Negation – Exponents ** Multiplication and division *, /, //, % Addition and subtraction, +, - The default order can be changed By using parenthesis (3 + 4) * 2 versus 3 + 4 * 2

Math Operator Order Exercise What is the result of 2 + 3 * 4 + 5 Where would you add parentheses to make it clear what is happening first How do you change it so that 2 + 3 happens first? How do you change it so that it multiplies the result of 2 + 3 and the result of 4 + 5?

But we don’t often work with JUST literals… Normally when we do calculations we want to store the calculations to use later: To do this we need to store values associated with a name (a variable) A variable is a name we designate to represent “something” in our program We use names to make our program more readable, so that the “something” is easily understood

Python Name Conventions must begin with a letter or _ Ab123 is OK, but 123ABC is not. may contain letters, digits, and underscores this_is_an_identifier_123 may be of any length upper and lower case letters are different LengthOfRope is not lengthofrope names starting with _ have special meaning. Be careful

Variable Objects Name Value X 7 X = 7 Python maintains a list of pairs for every variable: variable’s name variable’s value A variable is created when a value is assigned the first time. It associates a name and a value subsequent assignments update the associated value. we say name references value A variable’s type depends on what is assigned. Name Value X 7 X = 7

When = Doesn’t Mean Equal It is most confusing at first to see the following kind of expression: myInt = myInt + 7 You don’t have to be a math genius to figure out something is wrong there. What’s wrong is that = doesn’t mean equal

= is assignment In many computer languages, = means assignment. myInt = myInt + 7 lhs = rhs What “assignment” means is: evaluate all the “stuff” on the rhs of the = take the resulting value and associate it with the name on the lhs

More Assignment Example: x = 2 + 3 * 5 evaluate expression (2+3*5): 17 change the value of x to reference 17 Example (y has value 2): y = y + 3 evaluate expression (y+3): 5 change the value of y to reference 5