CSE 115. Introduction to Computer Science I

Similar documents
Module 2 - Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1

Chapter 17. Fundamental Concepts Expressed in JavaScript

cs1114 REVIEW of details test closed laptop period

Introduction to Computers. Laboratory Manual. Experiment #3. Elementary Programming, II

Lecture 2: Variables & Assignments

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands

LECTURE 3 C++ Basics Part 2

Introduction to Python and programming. Ruth Anderson UW CSE 160 Winter 2017

Lecture 1. Types, Expressions, & Variables

Chapter 2 Working with Data Types and Operators

Operators. Lecture 3 COP 3014 Spring January 16, 2018

Operators & Expressions

Lecture 2. Variables & Assignment

CIS 110: Introduction to Computer Programming

Full file at

Announcements. Lab Friday, 1-2:30 and 3-4:30 in Boot your laptop and start Forte, if you brought your laptop

Unit 3. Operators. School of Science and Technology INTRODUCTION

Introduction to Computation for the Humanities and Social Sciences. CS 3 Chris Tanner

Overview: Programming Concepts. Programming Concepts. Names, Values, And Variables

Overview: Programming Concepts. Programming Concepts. Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript

Information Science 1

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #23 Loops: Precedence of Operators

Slide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 Advance mode: Auto

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)

CSE 20. Lecture 4: Number System and Boolean Function. CSE 20: Lecture2

Chapter 3 Structure of a C Program

Expressions & Assignment Statements

CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output

CS 115 Lecture 4. More Python; testing software. Neil Moore

Algorithms and Programming I. Lecture#12 Spring 2015

Basic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2

Introduction to Python and Programming. 1. Python is Like a Calculator. You Type Expressions. Python Computes Their Values /2 2**3 3*4+5*6

Perl: Arithmetic, Operator Precedence and other operators. Perl has five basic kinds of arithmetic:

Lecture 3. More About C

Python The way of a program. Srinidhi H Asst Professor Dept of CSE, MSRIT

7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING

Module 3 SELECTION STRUCTURES 2/15/19 CSE 1321 MODULE 3 1

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

Introduction to TURING

Topic 4 Expressions and variables

CPS122 Lecture: From Python to Java

Expressions and Casting. Data Manipulation. Simple Program 11/5/2013

ENGR 102 Engineering Lab I - Computation

Fundamentals: Expressions and Assignment

Chapter 7. Expressions and Assignment Statements ISBN

Chapter 7. Expressions and Assignment Statements (updated edition 11) ISBN

9/10/10. Arithmetic Operators. Today. Assigning floats to ints. Arithmetic Operators & Expressions. What do you think is the output?

ENGR 101 Engineering Design Workshop

Expressions and Casting

ENGR (Socolofsky) Week 02 Python scripts

Add Subtract Multiply Divide

VARIABLES & ASSIGNMENTS

CPS122 Lecture: From Python to Java last revised January 4, Objectives:

COMP Primitive and Class Types. Yi Hong May 14, 2015

Chapter 7. Expressions and Assignment Statements

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

Operators. Java operators are classified into three categories:

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

Sir Muhammad Naveed. Arslan Ahmed Shaad ( ) Muhammad Bilal ( )

LECTURE 17. Expressions and Assignment

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

4/8/17. Admin. Assignment 5 BINARY. David Kauchak CS 52 Spring 2017

Lecture Numbers. Richard E Sarkis CSC 161: The Art of Programming

Prefix/Infix/Postfix Notation

ECE 122 Engineering Problem Solving with Java

GO - OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one.

CS112 Lecture: Working with Numbers

CS112 Lecture: Primitive Types, Operators, Strings

2 nd Week Lecture Notes

Basics of Java Programming

CSc 110, Spring 2017 Lecture 3: Expressions, Variables and Loops. Adapted from slides by Marty Stepp and Stuart Reges

CSE 142, Summer 2014

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

Basics of Java Programming variables, assignment, and input

Visual C# Instructor s Manual Table of Contents

Information Science 1

Lecture 3 Operators MIT AITI

QUIZ: What value is stored in a after this

Ex: If you use a program to record sales, you will want to remember data:

Lecture 3 Tao Wang 1

Lecture 1. Course Overview Types & Expressions

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators

Advanced Algorithms and Computational Models (module A)

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

CS1 Lecture 3 Jan. 18, 2019

Full file at

Introduction to: Computers & Programming: Review prior to 1 st Midterm

Expressions and Precedence. Last updated 12/10/18

CSE 452: Programming Languages. Outline of Today s Lecture. Expressions. Expressions and Control Flow

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.

SAMS Programming A/B. Lecture #1 Introductions July 3, Mark Stehlik

Chapter 7. Expressions and Assignment Statements ISBN

CS1 Lecture 3 Jan. 22, 2018

Variables, Constants, and Data Types

Getting Started. Office Hours. CSE 231, Rich Enbody. After class By appointment send an . Michigan State University CSE 231, Fall 2013

Building Java Programs

Values, Variables, Types & Arithmetic Expressions. Agenda

9/2/2016. Expressions are Used to Perform Calculations. ECE 120: Introduction to Computing. Five Arithmetic Operators on Numeric Types

Numerical Data. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

Transcription:

CSE 115 Introduction to Computer Science I

Note about posted slides The slides we post will sometimes contain additional slides/content, beyond what was presented in any one lecture. We do this so the slides more accurately reflect the content presented in all lecture sections, including questions that came up during lecture, and content that was presented on the board.

Announcements No required labs this week: Baldy 21 not staffed. No required labs next week, but Baldy 21 will be staffed. You are invited to come in to meet TAs and do some preliminary set-up. Required labs start the week of September 10.

Road map Ground rules Expressions Demo: expressions in Python

Ground rules

Ground rules Change is inevitable Programming languages come and go Programmers adapt to survive and thrive

Ground rules Programming fundamentals General principles common to all programming languages Specific details differ between programming languages

Ground rules Identification Code in the Python programming language will be identified using this logo: Code in the JavaScript programming language will be identified using this logo: Either logo may be placed next to the code segment whose language it identifies, or in the bottom right corner of the slide to apply to all code on the slide, as shown below:

Ground rules Correct not complete Everything we tell you should be correct* We will not tell you everything * but remember: to err is human

Ground rules Knowledge and skill will grow We will revisit topics and add to our knowledge over time Your skill will develop with practice

Road map Ground rules Expressions Demo: expressions in Python

Expressions An expression is a part of a program that has a value.

Expressions An expression is a part of a program that has a value. Examples: 3 3 + 5

Expressions An expression is a part of a program that has a value. Examples: 3 3 + 5 3 is a (simple) expression 3 is a (simple) expression 5 is a (simple) expression

Expressions An expression is a part of a program that has a value. 3 + 5 is a compound expression in which the + operator applies to two smaller expressions, 3 and 5, to create a larger expression. 3 3 + 5 3 is a (simple) expression 3 is a (simple) expression 5 is a (simple) expression

Expressions An expression is a part of a program that has a value. We can visualize/draw a compound expression as a "tree": + 3 5

Expressions Simple or Compound Simple expressions are atomic (cannot be decomposed) Compound expressions consist of subexpressions (can be decomposed) Examples: 3 17 Examples: 3 + 5-12 * 17

Simple Expressions Numeric literals int (eg 4037, 4_037) float (eg 3.1415, 6.022140857e23, 6.022_140_857e23) Boolean literals (False and True) Text literals string (eg "This is some text", 'This is also some text')

Compound Expressions A compound expression consists of one or more expressions AND one operator. unary negation operator (-) applied to an integer: -17 binary subtraction operator (-) applied to two integers: 43-5

Q: can an expression have more than one operator? For example, is 3 + 4 * 5 a valid expression?

Q: can an expression have more than one operator? For example, is 3 + 4 * 5 a valid expression? Yes, 3 + 4 * 5 is a valid expression, but like any compound expression is has a basic structure: operator expression expression

Q: can an expression have more than one operator? For example, is 3 + 4 * 5 a valid expression? In this example the expression on the right is itself a compound expression: operator expression operator expression expression

Q: can an expression have more than one operator? For example, is 3 + 4 * 5 a valid expression? Yes, 3 + 4 * 5 is a valid expression, but like any compound expression is has a certain structure: The "top level" expression adds the values of two smaller expressions, 3 and 4 * 5. + The product of 4 and 5 is 20. 3 * The sum of 3 and 20 is 23. 4 5

Expressions Order of Operations Follows Mathematic rules Multiplication and Division and before Addition and Subtraction Inside Parentheses first 6-3 + (1 + 4 * 5) resolves to 24

Most languages interpret arithmetic expressions by applying "order of operations", or precedence rules, that we're familiar with from ordinary arithmetic. Without assuming those rules, there's another possible interpretation: The "top level" expression multiplies the values of two smaller expressions, 3 + 4 and 5. * The sum of 3 + 4 and 7. + 5 The product of 7 and 5 is 35. 3 4

Compound Expressions Binary operators Addition (+) Subtraction (-) Multiplication (*) Division (/ and //) Modulo (%) Comparisons (<, <=, >, >=, ==,!=)

Expressions String (str) Expressions Expressions are evaluated to produce their values. The expression hello has value hello. The expression hello + world has value hello world. Note the space at the end of hello

Expressions String (str) Expressions Expressions are evaluated to produce their values. The expression hello has value hello. The expression hello + world has value hello world. The + operator in this context refers to the string concatenation operator.

Expressions Evaluation Expressions are evaluated to produce their values. The expression 3 has value 3. The expression 3 + 5 has value 8.

TopHat Before we dive into our LiveCoding demo, let's try out some TopHat questions!

Road map Ground rules Expressions Demo: expressions in Python

Demo: expressions in Python Show how to set up Che Live Coding demo