CSE 115. Introduction to Computer Science I

Size: px
Start display at page:

Download "CSE 115. Introduction to Computer Science I"

Transcription

1 CSE 115 Introduction to Computer Science I

2 Announcements Graded TopHat questions starts Fri. Sign up soon (& talk to us for help) Calling Function & Defining Function May need both lectures for UBInfinite exercises Even if you cannot finish, good idea to try starting work after class repl.it helps solve UBInfinite questions Only 1 st answer earns credit, so make it count Once code works, copy-and-paste answer back into UBInfinite

3 Help us help you! Search Piazza before posting: question might be answered When posting to Piazza: tell us what you think the problem is tell us what you've tried tell us where you're getting stuck Just posting a screenshot of code and saying 'help' isn't an effective learning strategy.

4 Help us help you! Search Piazza before posting: question might be answered When posting to Piazza: Tell us what YOU think problem is tell us what you've tried tell us where you're getting stuck Just posting a screenshot of code and saying 'help' isn't an effective learning strategy.

5 Help us help you! Search Piazza before posting: question might be answered When posting to Piazza: Tell us what YOU think problem is What you've tried to solve problem on your own tell us where you're getting stuck Just posting a screenshot of code and saying 'help' isn't an effective learning strategy.

6 Help us help you! Search Piazza before posting: question might be answered When posting to Piazza: Tell us what YOU think problem is What you've tried to solve problem on your own Explain which topic is confusing or hard-to-understand Just posting a screenshot of code and saying 'help' isn't an effective learning strategy.

7 Help us help you! Search Piazza before posting: question might be answered When posting to Piazza: Tell us what YOU think problem is What you've tried to solve problem on your own Explain which topic is confusing or hard-to-understand Developing good learning strategies is important part of class; upper-level classes (and bosses) need more than saying 'help'

8 Today's Plan Review Calling functions Final Ungraded TopHat Check Demo: function calls in Python

9 Variable Key Concept Name that has been assigned a value

10 Variables Assignment Statement name must appear on left-hand side of equal sign expression must appear on right-hand side of equal sign name = expression Starts by evaluating right-hand side of statement Variable then assigned value that was produced.

11 Variables in Expressions Variables also expressions After assigned value, variable usable as simple expression: x = 3 interesting_name = 6 interesting_name = x print(x * 5) school_name = 'UB' mascot = (school_name + " ") + "Bulls"

12 Expression Subgoals 1. Determine data type of all subexpressions 2. Check that data types usable in operation 3. Evaluate expression

13 Assignment Subgoals 1. Determine data type of all subexpressions 2. Check that data types usable in operation 3. Evaluate expression 4. Update variable's value

14 Today's Plan Calling functions

15 Functions Function is named block of code Execute code suite by calling the function Code a function call by typing name & providing arguments Good for common tasks, since can call function anytime

16 Functions Original Ideas From Math

17 Expressions Function Call Calling function like hiring it to have it step in & do its thing Function does all of work, you get any result it produces Function call is a complex expression: Function name is operation Argument(s) are subexpression(s)

18 Functions Python includes many built-in functions abs(num) min(num_1,num_2) max(num_1,num_2) pow(a_name,other_name) round(consistency_sucks) round(x,y) print(value_to_print)

19 Imports Also has functions defined in modules Must import module to use these functions import math Example using Python's math module hope_close_enough = math.sin( ) module_also_has_constants = math.pi/2 shorter = module_also_has_constants print( math.cos( shorter ) * 4 )

20 Function Call Subgoals 1. Determine whether function is built-in or in a module a) If in a module, check for import earlier in file 2. Write the function call 3. Determine whether arguments are appropriate a) Are there equal numbers of arguments & parameters? b) Is the type of each argument correct? 4. Determine if function returns a value & the type returned 5. Determine that the function value is used correctly

21 Function Calls Examples Expression pow starts with name of function min that should be executed abs print

22 Function Calls Examples ( 3, 2 ) Function call's ( 16/3, 4 ) arguments listed inside of (x) parentheses ( "Hi there!" )

23 Function Calls Examples pow( 3, 2 ) calculates 3 2 ; evaluates to value of 9 min( 16/3, 4 ) calculates minimum of 5⅓ & 4; evaluates to value of 4 x = -6 abs(x) calculates absolute value of -6; evaluates to value of 6 print( "Hi there!" )

24 Function Call Subgoals 1. Determine whether function is built-in or in a module a) If in a module, check for import earlier in file 2. Write the function call 3. Determine whether arguments are appropriate a) Are there equal numbers of arguments & parameters? b) Is the type of each argument correct? 4. Determine if function returns a value & the type returned 5. Determine that the function value is used correctly

25 Today's Plan Final Ungraded TopHat Check

26 Pick the True Statement Choose 1 statement which is true in Python: A. Only variables have types B. Variable can be assigned only once C.str literals can use either double (") or single (') quotes D.+ performs addition if both subexpressions are numbers & catenation if at least 1 is a str

27 Pick the True Statement Choose 1 statement which is true in Python: A. Only variables have types B. Variable can be assigned only once C.str literals can use either double (") or single (') quotes D.+ performs addition if both subexpressions are numbers & catenation if at least 1 is a str Convince Your Neighbor Your Answer Is Correct

28 Pick the True Statement Choose 1 statement which is true in Python: A. Only variables have types B. Variable can be assigned only once C.str literals can use either double (") or single (') quotes D.+ performs addition if both subexpressions are numbers & catenation if at least 1 is a str

29 Pick the True Statement Choose 1 statement which is true in Python: A. Only variables have types Only values have a type; variable provides "name" for location holding value temporarily

30 Pick the True Statement Choose 1 statement which is true in Python: Variables B. Variable can be assigned only once CAN be reassigned; just replaces what it's value is

31 Pick the True Statement Choose 1 statement which is true in Python: + does not combine a D. + performs addition if both subexpressions are numbers & catenation if at least 1 is a str number & a string

32 Pick the True Statement Choose 1 statement which is true in Python: But C.str literals can use either double (") or single (') quotes CANNOT use both in same literal

33 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / 6 4 smaller = min(answer, six * 9) 5 num = math.sin("180") 6 zero = abs(math.cos(math.pi)) 7 print(max(max(5, zero), smaller)) A. 1, 2, 3, 4, 5, 6, 7 D. 1, 3, 6, 7 B. 1, 2, 3, 4, 5, 7 E. 1, 2, 3, 4, 5 C. 1, 2, 3, 4, 6 F. No answers correct

34 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / 6 4 smaller = min(answer, six * 9) 5 num = math.sin("180") 6 zero = abs(math.cos(math.pi)) 7 print(max(max(5, zero), smaller)) Convince Your Neighbor Your Answer Is Correct A. 1, 2, 3, 4, 5, 6, 7 D. 1, 2, 3, 6, 7 B. 1, 2, 3, 4, 5, 7 E. 1, 2, 3, 4, 5 C. 1, 2, 3, 4, 6 F. No answers correct

35 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / 6 4 smaller = min(answer, six * 9) 5 num = math.sin("180") 6 zero = abs(math.cos(math.pi)) 7 print(max(max(5, zero), smaller)) A. 1, 2, 3, 4, 5, 6, 7 D. 1, 2, 3, 6, 7 B. 1, 2, 3, 4, 5, 7 E. 1, 2, 3, 4, 5 C. 1, 2, 3, 4, 6 F. No answers correct

36 Which Lines Legal? 1 import math A. 1, 2, 3, 4, 5, 6, 7 D. 1, 2, 3, 6, 7 B. 1, 2, 3, 4, 5, 7 E. 1, 2, 3, 4, 5 C. 1, 2, 3, 4, 6 F. No answers correct

37 Which Lines Legal? 1 import math 2 answer = A. 1, 2, 3, 4, 5, 6, 7 D. 1, 2, 3, 6, 7 B. 1, 2, 3, 4, 5, 7 E. 1, 2, 3, 4, 5 C. 1, 2, 3, 4, 6 F. No answers correct

38 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / A. 1, 2, 3, 4, 5, 6, 7 D. 1, 2, 3, 6, 7 B. 1, 2, 3, 4, 5, 7 E. 1, 2, 3, 4, 5 C. 1, 2, 3, 4, 6 F. No answers correct

39 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / 6 4 smaller = min(answer, six * 9) A. 1, 2, 3, 4, 5, 6, 7 B. 1, 2, 3, 4, 5, 7 E. 1, 2, 3, 4, 5 C. 1, 2, 3, 4, 6 F. No answers correct

40 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / 6 4 smaller = min(answer, six * 9) 5 num = math.sin("180") 6 7 C. 1, 2, 3, 4, 6 F. No answers correct

41 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / 6 4 smaller = min(answer, six * 9) 6 zero = abs(math.cos(math.pi)) 7 C. 1, 2, 3, 4, 6 F. No answers correct

42 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / 6 4 smaller = min(answer, six * 9) 6 math.cos(math.pi) 7 C. 1, 2, 3, 4, 6 F. No answers correct

43 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / 6 4 smaller = min(answer, six * 9) 6 math.cos(math.pi) π 7 C. 1, 2, 3, 4, 6 F. No answers correct

44 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / 6 4 smaller = min(answer, six * 9) 6 abs(math.cos(math.pi)) value of type float 7 C. 1, 2, 3, 4, 6 F. No answers correct

45 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / 6 4 smaller = min(answer, six * 9) 6 zero = abs(math.cos(math.pi)) value that must be a number 7 C. 1, 2, 3, 4, 6 F. No answers correct

46 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / 6 4 smaller = min(answer, six * 9) 6 zero = abs(math.cos(math.pi)) 7 C. 1, 2, 3, 4, 6 F. No answers correct

47 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / 6 4 smaller = min(answer, six * 9) 6 zero = abs(math.cos(math.pi)) 7 print(max(max(5, zero), smaller)) C. 1, 2, 3, 4, 6 F. No answers correct

48 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / 6 4 smaller = min(answer, six * 9) 6 zero = abs(math.cos(math.pi)) 7 max(5, zero) C. 1, 2, 3, 4, 6 F. No answers correct

49 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / 6 4 smaller = min(answer, six * 9) 6 zero = abs(math.cos(math.pi)) 7 max(max(5, some number zero), smaller) C. 1, 2, 3, 4, 6 F. No answers correct

50 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / 6 4 smaller = min(answer, six * 9) 6 zero = abs(math.cos(math.pi)) 7 print(max(max(5, a number that zero), has some smaller)) value C. 1, 2, 3, 4, 6 F. No answers correct

51 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / 6 4 smaller = min(answer, six * 9) 6 zero = abs(math.cos(math.pi)) 7 print(max(max(5, zero), smaller)) F. No answers correct

52 Which Lines Legal? 1 import math 2 answer = 42 3 six = answer / 6 4 smaller = min(answer, six * 9) 6 zero = abs(math.cos(math.pi)) 7 print(max(max(5, zero), smaller)) F. No answers correct

53 Today's Plan Demo: function calls in Python

54 Function Call Subgoals 1. Determine whether function is built-in or in a module a) If in a module, check for import earlier in file 2. Write the function call 3. Determine whether arguments are appropriate a) Are there equal numbers of arguments & parameters? b) Is the type of each argument correct? 4. Determine if function returns a value & the type returned 5. Determine that the function value is used correctly

Lecture 3. Functions & Modules

Lecture 3. Functions & Modules Lecture 3 Functions & Modules Labs this Week Lab 1 is due at the beginning of your lab If it is not yet by then, you cannot get credit Only exception is for students who added late (Those students should

More information

CSE 115. Introduction to Computer Science I

CSE 115. Introduction to Computer Science I 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

More information

CS 102 Lab 3 Fall 2012

CS 102 Lab 3 Fall 2012 Name: The symbol marks programming exercises. Upon completion, always capture a screenshot and include it in your lab report. Email lab report to instructor at the end of the lab. Review of built-in functions

More information

CS1 Lecture 3 Jan. 18, 2019

CS1 Lecture 3 Jan. 18, 2019 CS1 Lecture 3 Jan. 18, 2019 Office hours for Prof. Cremer and for TAs have been posted. Locations will change check class website regularly First homework assignment will be available Monday evening, due

More information

CS1 Lecture 3 Jan. 22, 2018

CS1 Lecture 3 Jan. 22, 2018 CS1 Lecture 3 Jan. 22, 2018 Office hours for me and for TAs have been posted, locations will change check class website regularly First homework available, due Mon., 9:00am. Discussion sections tomorrow

More information

CS 1110, LAB 2: FUNCTIONS AND ASSIGNMENTS

CS 1110, LAB 2: FUNCTIONS AND ASSIGNMENTS CS 1110, LAB 2: FUNCTIONS AND ASSIGNMENTS http://www.cs.cornell.edu/courses/cs1110/2017fa/labs/lab2/ First Name: Last Name: NetID: The purpose of this lab is to get you comfortable with using assignment

More information

Lecture 3. Functions & Modules

Lecture 3. Functions & Modules Lecture 3 Functions & Modules Labs this Week Lab 1 is due at the beginning of your lab If it is not yet by then, you cannot get credit Only exception is for students who added late (Those students should

More information

Lecture 3. Strings, Functions, & Modules

Lecture 3. Strings, Functions, & Modules Lecture 3 Strings, Functions, & Modules Labs this Week Lab 1 is due at the beginning of your lab If it is not yet by then, you cannot get credit Only exception is for students who added late (Those students

More information

CS 1110, LAB 2: ASSIGNMENTS AND STRINGS

CS 1110, LAB 2: ASSIGNMENTS AND STRINGS CS 1110, LAB 2: ASSIGNMENTS AND STRINGS http://www.cs.cornell.edu/courses/cs1110/2014fa/labs/lab02.pdf First Name: Last Name: NetID: The purpose of this lab is to get you comfortable with using assignment

More information

Selection statements. CSE 1310 Introduction to Computers and Programming Alexandra Stefan University of Texas at Arlington

Selection statements. CSE 1310 Introduction to Computers and Programming Alexandra Stefan University of Texas at Arlington Selection s CSE 1310 Introduction to Computers and Programming Alexandra Stefan University of Texas at Arlington 1 Book reference Book: The practice of Computing Using Python 2-nd edition Second hand book

More information

Lecture 3: Functions & Modules

Lecture 3: Functions & Modules http://www.cs.cornell.edu/courses/cs1110/2018sp Lecture 3: Functions & Modules (Sections 3.1-3.3) CS 1110 Introduction to Computing Using Python [E. Andersen, A. Bracy, D. Gries, L. Lee, S. Marschner,

More information

cs1114 REVIEW of details test closed laptop period

cs1114 REVIEW of details test closed laptop period python details DOES NOT COVER FUNCTIONS!!! This is a sample of some of the things that you are responsible for do not believe that if you know only the things on this test that they will get an A on any

More information

Lecture 1. Course Overview Types & Expressions

Lecture 1. Course Overview Types & Expressions Lecture 1 Course Overview Types & Expressions CS 1110 Spring 2012: Walker White Outcomes: Basics of (Java) procedural programming Usage of assignments, conditionals, and loops. Ability to write recursive

More information

Functions and abstraction. Ruth Anderson UW CSE 160 Winter 2017

Functions and abstraction. Ruth Anderson UW CSE 160 Winter 2017 Functions and abstraction Ruth Anderson UW CSE 160 Winter 2017 1 Functions In math, you use functions: sine, cosine, In math, you define functions: f(x) = x 2 + 2x + 1 In Python: A function packages up

More information

Lecture 7. Memory in Python

Lecture 7. Memory in Python Lecture 7 Memory in Python Announcements For This Lecture Readings Reread Chapter 3 No reading for Thursday Lab Work on Assignment Credit when submit A Nothing else to do Assignment Moved to Fri, Sep.

More information

Python 1: Intro! Max Dougherty Andrew Schmitt

Python 1: Intro! Max Dougherty Andrew Schmitt Python 1: Intro! Max Dougherty Andrew Schmitt Computational Thinking Two factors of programming: The conceptual solution to a problem. Solution syntax in a programming language BJC tries to isolate and

More information

Lecture 2: Variables & Assignments

Lecture 2: Variables & Assignments http://www.cs.cornell.edu/courses/cs1110/2018sp Lecture 2: Variables & Assignments (Sections 2.1-2.3,2.5) CS 1110 Introduction to Computing Using Python [E. Andersen, A. Bracy, D. Gries, L. Lee, S. Marschner,

More information

Downloaded from Chapter 2. Functions

Downloaded from   Chapter 2. Functions Chapter 2 Functions After studying this lesson, students will be able to: Understand and apply the concept of module programming Write functions Identify and invoke appropriate predefined functions Create

More information

CS110: PROGRAMMING LANGUAGE I

CS110: PROGRAMMING LANGUAGE I CS110: PROGRAMMING LANGUAGE I Computer Science Department Lecture 8: Methods Lecture Contents: 2 Introduction Program modules in java Defining Methods Calling Methods Scope of local variables Passing Parameters

More information

61A LECTURE 1 FUNCTIONS, VALUES. Steven Tang and Eric Tzeng June 24, 2013

61A LECTURE 1 FUNCTIONS, VALUES. Steven Tang and Eric Tzeng June 24, 2013 61A LECTURE 1 FUNCTIONS, VALUES Steven Tang and Eric Tzeng June 24, 2013 Welcome to CS61A! The Course Staff - Lecturers Steven Tang Graduated L&S CS from Cal Back for a PhD in Education Eric Tzeng Graduated

More information

Lecture 2. Variables & Assignment

Lecture 2. Variables & Assignment Lecture 2 Variables & Assignment Announcements for Today If Not Done Already Enroll in Piazza Sign into CMS Fill out the Survey Complete AI Quiz Read the tetbook Chapter 1 (browse) Chapter 2 (in detail)

More information

ECS Baruch Lab 5 Spring 2019 Name NetID (login, like , not your SUID)

ECS Baruch Lab 5 Spring 2019 Name NetID (login, like  , not your SUID) ECS 102 - Baruch Lab 5 Spring 2019 Name NetID (login, like email, not your SUID) Today you will be doing some more experiments in the shell. Create a file Lab5.txt. In this file you will be asked to save

More information

Functions with Parameters and Return Values

Functions with Parameters and Return Values CS101, Spring 2015 Functions with Parameters and Return Values Lecture #4 Last week we covered Objects and Types Variables Methods Tuples Roadmap Last week we covered Objects and Types Variables Methods

More information

CSE 115. Introduction to Computer Science I

CSE 115. Introduction to Computer Science I CSE 115 Introduction to Computer Science I Help us help you! When posting to Piazza: tell us what you think the problem is tell us what you've tried tell us where you're getting stuck Just posting a screenshot

More information

Lecture 9. Memory and Call Stacks

Lecture 9. Memory and Call Stacks Lecture 9 Memory and Call Stacks Announcements for Today Assignment 1 Reading We have started grading! Should have your grade tomorrow morning Resubmit until correct If you were close Will get feedback

More information

CSC 120 Computer Science for the Sciences. Week 1 Lecture 2. UofT St. George January 11, 2016

CSC 120 Computer Science for the Sciences. Week 1 Lecture 2. UofT St. George January 11, 2016 CSC 120 Computer Science for the Sciences Week 1 Lecture 2 UofT St. George January 11, 2016 Introduction to Python & Foundations of computer Programming Variables, DataTypes, Arithmetic Expressions Functions

More information

61A Lecture 2. Wednesday, September 4, 2013

61A Lecture 2. Wednesday, September 4, 2013 61A Lecture 2 Wednesday, September 4, 2013 Names, Assignment, and User-Defined Functions (Demo) Types of Expressions Primitive expressions: 2 add 'hello' Number or Numeral Name String Call expressions:

More information

Lecture 1. Course Overview, Python Basics

Lecture 1. Course Overview, Python Basics Lecture 1 Course Overview, Python Basics We Are Very Full! Lectures are at fire-code capacity. We cannot add sections or seats to lectures You may have to wait until someone drops No auditors are allowed

More information

CSCI 121: Anatomy of a Python Script

CSCI 121: Anatomy of a Python Script CSCI 121: Anatomy of a Python Script Python Scripts We start by a Python script: A text file containing lines of Python code. Each line is a Python statement. The Python interpreter (the python3 command)

More information

Lecture 1. Course Overview, Python Basics

Lecture 1. Course Overview, Python Basics Lecture 1 Course Overview, Python Basics We Are Very Full! Lectures and Labs are at fire-code capacity We cannot add sections or seats to lectures You may have to wait until someone drops No auditors are

More information

CS 141, Lecture 3. Please login to the Math/Programming profile, and look for IDLE (3.4 or the unnumbered. <-- fine <-- fine <-- broken

CS 141, Lecture 3. Please login to the Math/Programming profile, and look for IDLE (3.4 or the unnumbered. <-- fine <-- fine <-- broken CS 141, Lecture 3 Please login to the Math/Programming profile, and look for IDLE (3.4 or the unnumbered one are fine)

More information

CSE 115. Introduction to Computer Science I

CSE 115. Introduction to Computer Science I CSE 115 Introduction to Computer Science I Progress In UBInfinite? A. Haven't started B. Earned 3 stars in "Calling Functions" C. Earned 3 stars in "Defining Functions" D. Earned 3 stars in "Conditionals"

More information

Module 01: Introduction to Programming in Python

Module 01: Introduction to Programming in Python Module 01: Introduction to Programming in Python Topics: Course Introduction Introduction to Python basics Readings: ThinkP 1,2,3 1 Finding course information https://www.student.cs.uwaterloo.ca/~cs116/

More information

Python Programming Exercises 1

Python Programming Exercises 1 Python Programming Exercises 1 Notes: throughout these exercises >>> preceeds code that should be typed directly into the Python interpreter. To get the most out of these exercises, don t just follow them

More information

Introduction to Python. Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas

Introduction to Python. Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas Introduction to Python Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas If you have your own PC, download and install a syntax-highlighting text editor and Python

More information

Python Lists: Example 1: >>> items=["apple", "orange",100,25.5] >>> items[0] 'apple' >>> 3*items[:2]

Python Lists: Example 1: >>> items=[apple, orange,100,25.5] >>> items[0] 'apple' >>> 3*items[:2] Python Lists: Lists are Python's compound data types. A list contains items separated by commas and enclosed within square brackets ([]). All the items belonging to a list can be of different data type.

More information

Lecture 1. Types, Expressions, & Variables

Lecture 1. Types, Expressions, & Variables Lecture 1 Types, Expressions, & Variables About Your Instructor Director: GDIAC Game Design Initiative at Cornell Teach game design (and CS 1110 in fall) 8/29/13 Overview, Types & Expressions 2 Helping

More information

Lecture 4. Defining Functions

Lecture 4. Defining Functions Lecture 4 Defining Functions Academic Integrity Quiz Remember: quiz about the course AI policy Have posted grades for completed quizes Right now, missing ~130 enrolled students If did not receive at least

More information

Lecture 4. Defining Functions

Lecture 4. Defining Functions Lecture 4 Defining Functions Academic Integrity Quiz Reading quiz about the course AI policy Go to http://www.cs.cornell.edu/courses/cs11110/ Click Academic Integrity in side bar Read and take quiz in

More information

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

Week 2: Console I/O and Operators Arithmetic Operators. Integer Division. Arithmetic Operators. Gaddis: Chapter 3 (2.14,3.1-6,3.9-10,5.

Week 2: Console I/O and Operators Arithmetic Operators. Integer Division. Arithmetic Operators. Gaddis: Chapter 3 (2.14,3.1-6,3.9-10,5. Week 2: Console I/O and Operators Gaddis: Chapter 3 (2.14,3.1-6,3.9-10,5.1) CS 1428 Fall 2014 Jill Seaman 1 2.14 Arithmetic Operators An operator is a symbol that tells the computer to perform specific

More information

Teaching London Computing

Teaching London Computing Teaching London Computing A Level Computer Science Topic 1: GCSE Python Recap William Marsh School of Electronic Engineering and Computer Science Queen Mary University of London Aims What is programming?

More information

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

Introduction to: Computers & Programming: Review prior to 1 st Midterm Introduction to: Computers & Programming: Review prior to 1 st Midterm Adam Meyers New York University Summary Some Procedural Matters Summary of what you need to Know For the Test and To Go Further in

More information

CS 1110, LAB 1: EXPRESSIONS AND ASSIGNMENTS First Name: Last Name: NetID:

CS 1110, LAB 1: EXPRESSIONS AND ASSIGNMENTS   First Name: Last Name: NetID: CS 1110, LAB 1: EXPRESSIONS AND ASSIGNMENTS http://www.cs.cornell.edu/courses/cs1110/2018sp/labs/lab01/lab01.pdf First Name: Last Name: NetID: Learning goals: (1) get hands-on experience using Python in

More information

COMP1730/COMP6730 Programming for Scientists. Functions

COMP1730/COMP6730 Programming for Scientists. Functions COMP1730/COMP6730 Programming for Scientists Functions Lecture outline * Function definition. * Function calls & order of evaluation. * Assignments in functions; local variables. * Function testing. Functions

More information

Python Intro GIS Week 1. Jake K. Carr

Python Intro GIS Week 1. Jake K. Carr GIS 5222 Week 1 Why Python It s simple and easy to learn It s free - open source! It s cross platform IT S expandable!! Why Python: Example Consider having to convert 1,000 shapefiles into feature classes

More information

Introduction to Python. Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas

Introduction to Python. Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas Introduction to Python Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas If you have your own PC, download and install a syntax-highlighting text editor and Python

More information

Lecture 4. Defining Functions

Lecture 4. Defining Functions Lecture 4 Defining Functions Academic Integrity Quiz Remember: quiz about the course AI policy Have posted grades for completed quizes Right now, missing ~90 enrolled students If did not receive perfect,

More information

Name: Date: Absolute Value Transformations

Name: Date: Absolute Value Transformations Name: Date: Absolute Value Transformations Vocab: Absolute value is the measure of the distance awa from zero on a number line. Since absolute value is the measure of distance it can never be negative!

More information

CS 1110, LAB 3: MODULES AND TESTING First Name: Last Name: NetID:

CS 1110, LAB 3: MODULES AND TESTING   First Name: Last Name: NetID: CS 1110, LAB 3: MODULES AND TESTING http://www.cs.cornell.edu/courses/cs11102013fa/labs/lab03.pdf First Name: Last Name: NetID: The purpose of this lab is to help you better understand functions, and to

More information

NOTE: All references to Python on this exam mean Python 3, so you should answer accordingly.

NOTE: All references to Python on this exam mean Python 3, so you should answer accordingly. Name: (as it would appear on official course roster) Umail address: EXAM: : Midterm Exam ready? date points true Thu 08/24 09:30AM 100 @umail.ucsb.edu 1 You may not collaborate on this exam with anyone.

More information

CS61A Lecture 1. Amir Kamil UC Berkeley January 23, 2013

CS61A Lecture 1. Amir Kamil UC Berkeley January 23, 2013 CS61A Lecture 1 Amir Kamil UC Berkeley January 23, 2013 Welcome to CS61A! The Course Staff I ve been at Berkeley a long time, and took CS61A a while back. Read the course info to find out when! TAs essentially

More information

Python for Non-programmers

Python for Non-programmers Python for Non-programmers A Gentle Introduction 1 Yann Tambouret Scientific Computing and Visualization Information Services & Technology Boston University 111 Cummington St. yannpaul@bu.edu Winter 2013

More information

Class C{ int a; } what variables below are objects : a. C c; b. String str; c. Scanner scanner; d. int num; e. float f;

Class C{ int a; } what variables below are objects : a. C c; b. String str; c. Scanner scanner; d. int num; e. float f; Class C{ int a; } what variables below are objects : a. C c; b. String str; c. Scanner scanner; d. int num; e. float f; Starting Out with Java: From Control Structures Through Objects Sixth Edition Chapter

More information

Admin CS41B MACHINE. Midterm topics. Admin 2/11/16. Midterm next Thursday in-class (2/18) SML. recursion. math. David Kauchak CS 52 Spring 2016

Admin CS41B MACHINE. Midterm topics. Admin 2/11/16. Midterm next Thursday in-class (2/18) SML. recursion. math. David Kauchak CS 52 Spring 2016 Admin! Assignment 3! due Monday at :59pm! Academic honesty CS4B MACHINE David Kauchak CS 5 Spring 6 Admin Midterm next Thursday in-class (/8)! Comprehensive! Closed books, notes, computers, etc.! Except,

More information

Getting Started Values, Expressions, and Statements CS GMU

Getting Started Values, Expressions, and Statements CS GMU Getting Started Values, Expressions, and Statements CS 112 @ GMU Topics where does code go? values and expressions variables and assignment 2 where does code go? we can use the interactive Python interpreter

More information

Built-in Types of Data

Built-in Types of Data Built-in Types of Data Types A data type is set of values and a set of operations defined on those values Python supports several built-in data types: int (for integers), float (for floating-point numbers),

More information

Course Overview, Python Basics

Course Overview, Python Basics CS 1110: Introduction to Computing Using Python Lecture 1 Course Overview, Python Basics [Andersen, Gries, Lee, Marschner, Van Loan, White] Interlude: Why learn to program? (which is subtly distinct from,

More information

Name: Partner: Python Activity 9: Looping Structures: FOR Loops

Name: Partner: Python Activity 9: Looping Structures: FOR Loops Name: Partner: Python Activity 9: Looping Structures: FOR Loops Learning Objectives Students will be able to: Content: Explain the difference between while loop and a FOR loop Explain the syntax of a FOR

More information

ENGR (Socolofsky) Week 02 Python scripts

ENGR (Socolofsky) Week 02 Python scripts ENGR 102-213 (Socolofsky) Week 02 Python scripts Listing for script.py 1 # data_types.py 2 # 3 # Lecture examples of using various Python data types and string formatting 4 # 5 # ENGR 102-213 6 # Scott

More information

CS 303E Fall 2011 Exam 2 Solutions and Criteria November 2, Good Luck!

CS 303E Fall 2011 Exam 2 Solutions and Criteria November 2, Good Luck! CS 303E Fall 2011 Exam 2 Solutions and Criteria November 2, 2011 Name: EID: Section Number: Friday discussion time (circle one): 9-10 10-11 11-12 12-1 2-3 Friday discussion TA(circle one): Wei Ashley Answer

More information

Python Boot Camp. Day 3

Python Boot Camp. Day 3 Python Boot Camp Day 3 Agenda 1. Review Day 2 Exercises 2.Getting input from the user, Interview Lab 3.Scopes 4.Conditionals, Mood Ring Lab 5.Recursion, Recursion Lab Day 2 Exercises Think Python Ch. 3

More information

61A Lecture 2. Friday, August 28, 2015

61A Lecture 2. Friday, August 28, 2015 61A Lecture 2 Friday, August 28, 2015 Names, Assignment, and User-Defined Functions (Demo) Types of Expressions Primitive expressions: 2 add 'hello' Number or Numeral Name String Call expressions: max

More information

Comp Assignment 4: Commands and Graphics

Comp Assignment 4: Commands and Graphics Comp 401 - Assignment 4: Commands and Graphics Date Assigned: Thu Sep 12, 2013 Completion Date: Fri Sep 20, 2013 Early Submission Date: Wed Sep 18, 2013 This assignment has two parts having to do with

More information

Lecture 3: Functions & Modules (Sections ) CS 1110 Introduction to Computing Using Python

Lecture 3: Functions & Modules (Sections ) CS 1110 Introduction to Computing Using Python http://www.cs.cornell.edu/courses/cs1110/2019sp Lecture 3: Functions & Modules (Sections 3.1-3.3) CS 1110 Introduction to Computing Using Python [E. Andersen, A. Bracy, D. Gries, L. Lee, S. Marschner,

More information

Excel Formulas 2018 Cindy Kredo Page 1 of 23

Excel Formulas 2018 Cindy Kredo Page 1 of 23 Excel file: Excel_Formulas_BeyondIntro_Data.xlsx Lab One: Sumif, AverageIf and Countif Goal: On the Demographics tab add formulas in Cells C32, D32 and E32 using the above functions. Use the cross-hair

More information

Computer Science 1 CSCI-1100 Spring Semester 2015 Exam 1 Overview and Practice Questions

Computer Science 1 CSCI-1100 Spring Semester 2015 Exam 1 Overview and Practice Questions Computer Science 1 CSCI-1100 Spring Semester 2015 Exam 1 Overview and Practice Questions REMINDERS Exam 1 will be held Monday, March 2, 2015. Most of you will take the exam from 6:00-7:50PM in DCC 308.

More information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 10: OCT. 6TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 10: OCT. 6TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 10: OCT. 6TH INSTRUCTOR: JIAYIN WANG 1 Notice Assignments Reading Assignment: Chapter 3: Introduction to Parameters and Objects The Class 10 Exercise

More information

CS 1803 Individual Homework 2 Conditionals & Loops Due: Wednesday, February 2 nd, before 6 PM Out of 100 points

CS 1803 Individual Homework 2 Conditionals & Loops Due: Wednesday, February 2 nd, before 6 PM Out of 100 points CS 1803 Individual Homework 2 Conditionals & Loops Due: Wednesday, February 2 nd, before 6 PM Out of 100 points Files to submit: 1. HW2.py This is an INDIVIDUAL assignment! Collaboration at a reasonable

More information

CSE450. Translation of Programming Languages. Lecture 14: Arrays!

CSE450. Translation of Programming Languages. Lecture 14: Arrays! CSE450 Translation of Programming Languages Lecture 14: Arrays! Arrays in Tubular Arrays in Tubular have the following form: array(type) var_name; This should create a new variable that is an array of

More information

Intro. Classes & Inheritance

Intro. Classes & Inheritance Intro Functions are useful, but they're not always intuitive. Today we're going to learn about a different way of programming, where instead of functions we will deal primarily with objects. This school

More information

The Three Rules. Program. What is a Computer Program? 5/30/2018. Interpreted. Your First Program QuickStart 1. Chapter 1

The Three Rules. Program. What is a Computer Program? 5/30/2018. Interpreted. Your First Program QuickStart 1. Chapter 1 The Three Rules Chapter 1 Beginnings Rule 1: Think before you program Rule 2: A program is a human-readable essay on problem solving that also executes on a computer Rule 3: The best way to improve your

More information

CMSC 201 Computer Science I for Majors

CMSC 201 Computer Science I for Majors CMSC 201 Computer Science I for Majors Lecture 02 Intro to Python Syllabus Last Class We Covered Grading scheme Academic Integrity Policy (Collaboration Policy) Getting Help Office hours Programming Mindset

More information

Chapter 5 Methods. Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved.

Chapter 5 Methods. Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved. Chapter 5 Methods rights reserved. 0132130807 1 Opening Problem Find the sum of integers from 1 to 10, from 20 to 30, and from 35 to 45, respectively. rights reserved. 0132130807 2 1 Problem int sum =

More information

Copied from: https://www.cs.hmc.edu/twiki/bin/view/cs5/lab1b on 3/20/2017

Copied from: https://www.cs.hmc.edu/twiki/bin/view/cs5/lab1b on 3/20/2017 Hw 1, Part 2 (Lab): Functioning smoothly! Using built-in functions Copied from: https://www.cs.hmc.edu/twiki/bin/view/cs5/lab1b on 3/20/2017 First, try out some of Python's many built-in functions. These

More information

Designing Loops and General Debug Pre-Defined Functions in C++ CS 16: Solving Problems with Computers I Lecture #6

Designing Loops and General Debug Pre-Defined Functions in C++ CS 16: Solving Problems with Computers I Lecture #6 Designing Loops and General Debug Pre-Defined Functions in C++ CS 16: Solving Problems with Computers I Lecture #6 Ziad Matni Dept. of Computer Science, UCSB Announcements Homework #5 due today Lab #3

More information

Starting. Read: Chapter 1, Appendix B from textbook.

Starting. Read: Chapter 1, Appendix B from textbook. Read: Chapter 1, Appendix B from textbook. Starting There are two ways to run your Python program using the interpreter 1 : from the command line or by using IDLE (which also comes with a text editor;

More information

Semester 2. Structured Programming. Modular Programming Top-down design. Essentials covered. More complex programming topics.

Semester 2. Structured Programming. Modular Programming Top-down design. Essentials covered. More complex programming topics. Semester 2 Essentials covered Basis of problem solving More complex programming topics Modular programming Lists, tuples, strings & arrays File handling Dr. Hugh Melvin, Dept. of IT, NUI,G 1 Structured

More information

Lecture 12. Lists (& Sequences)

Lecture 12. Lists (& Sequences) Lecture Lists (& Sequences) Announcements for Today Reading Read 0.0-0., 0.4-0.6 Read all of Chapter 8 for Tue Prelim, Oct th 7:30-9:30 Material up to October 3rd Study guide net week Conflict with Prelim

More information

INF121: Functional Algorithmic and Programming

INF121: Functional Algorithmic and Programming INF121: Functional Algorithmic and Programming Lecture 2: Identifiers and functions Academic Year 2011-2012 Identifiers The notion of identifier A fundamental concept of programming languages: associating

More information

Lecture 3. Input, Output and Data Types

Lecture 3. Input, Output and Data Types Lecture 3 Input, Output and Data Types Goals for today Variable Types Integers, Floating-Point, Strings, Booleans Conversion between types Operations on types Input/Output Some ways of getting input, and

More information

CIS192 Python Programming. Robert Rand. August 27, 2015

CIS192 Python Programming. Robert Rand. August 27, 2015 CIS192 Python Programming Introduction Robert Rand University of Pennsylvania August 27, 2015 Robert Rand (University of Pennsylvania) CIS 192 August 27, 2015 1 / 30 Outline 1 Logistics Grading Office

More information

Most of the class will focus on if/else statements and the logical statements ("conditionals") that are used to build them. Then I'll go over a few

Most of the class will focus on if/else statements and the logical statements (conditionals) that are used to build them. Then I'll go over a few With notes! 1 Most of the class will focus on if/else statements and the logical statements ("conditionals") that are used to build them. Then I'll go over a few useful functions (some built into standard

More information

COMP 250. Lecture 36 MISC. - beyond COMP final exam comments

COMP 250. Lecture 36 MISC. - beyond COMP final exam comments COMP 250 Lecture 36 MISC - beyond COMP 250 - final exam comments Dec 5, 2016 1 202 Intro Program MATH (prereqs for many upper level COMP courses) 206 Software Systems 273 Computer Systems 250 Intro Comp

More information

Lecture 4: Defining Functions

Lecture 4: Defining Functions http://www.cs.cornell.edu/courses/cs0/208sp Lecture 4: Defining Functions (Ch. 3.4-3.) CS 0 Introduction to Computing Using Python [E. Andersen, A. Bracy, D. Gries, L. Lee, S. Marschner, C. Van Loan, W.

More information

Fundamentals: Expressions and Assignment

Fundamentals: Expressions and Assignment Fundamentals: Expressions and Assignment A typical Python program is made up of one or more statements, which are executed, or run, by a Python console (also known as a shell) for their side effects e.g,

More information

Please write your name and username here legibly: C212/A592 6W2 Summer 2017 Early Evaluation Exam: Fundamental Programming Structures in Java

Please write your name and username here legibly: C212/A592 6W2 Summer 2017 Early Evaluation Exam: Fundamental Programming Structures in Java Please write your name and username here legibly: C212/A592 6W2 Summer 2017 Early Evaluation Exam: Fundamental Programming Structures in Java Use BigDecimal (a class defined in package java.math) to write

More information

Variables, Constants, and Data Types

Variables, Constants, and Data Types Variables, Constants, and Data Types Strings and Escape Characters Primitive Data Types Variables, Initialization, and Assignment Constants Reading for this lecture: Dawson, Chapter 2 http://introcs.cs.princeton.edu/python/12types

More information

6.009 Fundamentals of Programming

6.009 Fundamentals of Programming 6.009 Fundamentals of Programming Lecture 5: Custom Types Adam Hartz hz@mit.edu 6.009: Goals Our goals involve helping you develop as a programmer, in multiple aspects: Programming: Analyzing problems,

More information

6.001 Notes: Section 15.1

6.001 Notes: Section 15.1 6.001 Notes: Section 15.1 Slide 15.1.1 Our goal over the next few lectures is to build an interpreter, which in a very basic sense is the ultimate in programming, since doing so will allow us to define

More information

Slide 1 Side Effects Duration: 00:00:53 Advance mode: Auto

Slide 1 Side Effects Duration: 00:00:53 Advance mode: Auto Side Effects The 5 numeric operators don't modify their operands Consider this example: int sum = num1 + num2; num1 and num2 are unchanged after this The variable sum is changed This change is called a

More information

CIS192: Python Programming

CIS192: Python Programming CIS192: Python Programming Introduction Harry Smith University of Pennsylvania January 18, 2017 Harry Smith (University of Pennsylvania) CIS 192 Lecture 1 January 18, 2017 1 / 34 Outline 1 Logistics Rooms

More information

Section 3. Topics Covered

Section 3. Topics Covered Section 3 Topics Covered " Calculating using formulas... 3-2 " Copying formulas... 3-7 " Using absolute cell addresses... 3-13 " Calculating results using AutoCalculate... 3-18# " Using functions... 3-21

More information

ADOBE BUSINESS DIRECT SALES OUTBOUND TEMPLATES

ADOBE BUSINESS DIRECT SALES OUTBOUND  TEMPLATES ADOBE BUSINESS DIRECT SALES OUTBOUND EMAIL TEMPLATES TEMPLATE 1: FIRST ATTEMPTED OUTBOUND PHONE CONVERSATION, NO ANSWER Use: Send this email after trying to call a prospective customer who did not answer.

More information

Variable and Data Type 2

Variable and Data Type 2 The Islamic University of Gaza Faculty of Engineering Dept. of Computer Engineering Intro. To Computers (LNGG 1003) Lab 3 Variable and Data Type 2 Eng. Ibraheem Lubbad March 2, 2017 Python Lists: Lists

More information

Expressions. Eric Roberts Handout #3 CSCI 121 January 30, 2019 Expressions. Grace Murray Hopper. Arithmetic Expressions.

Expressions. Eric Roberts Handout #3 CSCI 121 January 30, 2019 Expressions. Grace Murray Hopper. Arithmetic Expressions. Eric Roberts Handout #3 CSCI 121 January 30, 2019 Expressions Grace Murray Hopper Expressions Eric Roberts CSCI 121 January 30, 2018 Grace Hopper was one of the pioneers of modern computing, working with

More information

Java Programming Fundamentals - Day Instructor: Jason Yoon Website:

Java Programming Fundamentals - Day Instructor: Jason Yoon Website: Java Programming Fundamentals - Day 1 07.09.2016 Instructor: Jason Yoon Website: http://mryoon.weebly.com Quick Advice Before We Get Started Java is not the same as javascript! Don t get them confused

More information

Section 1.1 Definitions and Properties

Section 1.1 Definitions and Properties Section 1.1 Definitions and Properties Objectives In this section, you will learn to: To successfully complete this section, you need to understand: Abbreviate repeated addition using Exponents and Square

More information

COMP 110 Introduction to Programming. What did we discuss?

COMP 110 Introduction to Programming. What did we discuss? COMP 110 Introduction to Programming Fall 2015 Time: TR 9:30 10:45 Room: AR 121 (Hanes Art Center) Jay Aikat FB 314, aikat@cs.unc.edu Previous Class What did we discuss? COMP 110 Fall 2015 2 1 Today Announcements

More information

GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004

GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004 GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004 Functions and Program Structure Today we will be learning about functions. You should already have an idea of their uses. Cout

More information