mith College Computer Science Week 9 CSC111 - Fall 2018 Dominique Thiébaut
|
|
- Patricia Murphy
- 6 years ago
- Views:
Transcription
1 mith College Computer Science Week 9 CSC111 - Fall 2018 Dominique Thiébaut dthiebaut@smith.edu
2 Dealing with Exceptions (Chapter 7.4) Defining Classes (Chapter 10)
3 # getinput: returns an integer larger # than 0. Expected to be robust def getinput(): while True: x = eval( input( "Enter a positive int: " ) ) if x >= 0: return x print( "Invalid number: Please try again: " ) def main(): num = getinput() print( "you entered", num ) main()
4
5 Exception
6 RAM Processor Keyboard Disk Python Program Network
7 RAM Processor Keyboard Operating System Disk Python Program Network
8 RAM Processor Keyboard Operating System Disk Python Program Events Network
9 RAM Processor Keyboard Operating System Disk Python Program Exception Network
10 Exception Some exceptions are generated by the Python interpreter
11 RAM Processor Keyboard Operating System Disk Python Program Exception Network
12 RAM Processor Keyboard Operating System Disk Python Program Network
13 RAM Processor Keyboard Operating System Disk Python Program Network If Exception generated by Python Interpreter, OS "kills" the Python Program
14 RAM Processor Keyboard Operating System Disk Python Program We want to prevent exceptions from going all the way up to the operating system Network
15 Python Program
16 Python Program We want to "isolate" dangerous code areas We want a tight isolation blocks around the potentially dangerous code sections
17 Coding exceptions is a pain in the neck but exceptions are an integral part of programming
18 Try/Except Statement try: python code that might generate an exception Except exceptionxyz : python code to run in case there's an exception
19
20
21 Solution
22 Approach to Handling Exceptions 1. Run code without try/except statements 2. Test thoroughly 3. Fix whatever can be fixed with "regular" python code 4. Record all exceptions that cannot be fixed otherwise, and add try/except to catch them. 5. Make the try section as small as possible.
23 Multiple Exceptions (taken from Zelle)
24 Solving Equation of Degree 2
25 Solving Equation of Degree 2
26 Hardening the Function
27 Dealing with Exceptions (Chapter 7.4) CSV Files Defining Classes (Chapter 10)
28 CSV Format Comma-Separated Values Very popular way of representing information where all records have the same format Easy to implement Examples: data/csv/csv.html
29 Example "Name", "Sex", "Age", "Height (in)", "Weight (lbs)" "Alex", "M", 41, 74, 170 "Bert", "M", 42, 68, 166 "Carl", "M", 32, 70, 155 "Dave", "M", 39, 72, 167 "Elly", "F", 30, 66, 124 "Fran", "F", 33, 66, 115 "Gwen", "F", 26, 64, 121 "Hank", "M", 30, 71, 158 "Ivan", "M", 53, 72, 175 "Jake", "M", 32, 69, 143 "Kate", "F", 47, 69, 139 "Luke", "M", 34, 72, 163 "Myra", "F", 23, 62, 98 "Neil", "M", 36, 75, 160 "Omar", "M", 38, 70, 145 "Page", "F", 31, 67, 135 "Quin", "M", 29, 71, 176 "Ruth", "F", 28, 65, 131
30 Reading CSV Files
31 CSV and MS Excel
32 CSV and MS Excel
33 Dealing with Exceptions (Chapter 7.4) CSV Files Defining Classes (Chapter 10)
34 Dealing with Exceptions (Chapter 7.4) CSV Files Defining Classes (Chapter 10)
35 Coding Dice
36 Using the Objects # Create 2 dice, one with 6 sides, one with 8 d1 = Die( 6 ) d2 = Die( 8 ) # Roll both dice d1.roll( ) d2.roll( ) # display their value print( "Die 1: ", d1.getvalue() ) print( "Die 2: ", d2.getvalue() )
37 We need to create the blueprint for a box (object) value nosides roll()
38 We need to create the blueprint for the box value nosides getvalue()
39 Blueprint class def
40 Blueprint class def blueprint object
41 object Blueprint class def blueprint object
42 object object Blueprint class def blueprint object
43 object object Blueprint class def blueprint = class object
44 A Class for a Die # libraries from random import randrange # a class for a die class Die: def init ( self, n ): self.nosides = n self.value = 1 Blueprint class def def roll( self ): self.value = randrange( 1, self.nosides+1 ) def getvalue( self ): return self.value
45 A Die Class # libraries import random constructor # a class for a die class Die: def init ( self, n ): self.nosides = n self.value = 1 def roll( self ): self.value = random.randrange( 1, self.nosides+1 ) def getvalue( self ): return self.value
46 A Die Class # libraries import random # Create 2 dice, one with 6 sides d1 = Die( 6 ) d2 = Die( 8 ) # Roll both dice d1.roll( ) d2.roll( ) # display their value print( "Die 1: ", d1.getvalue() ) print( "Die 2: ", d2.getvalue() ) # a class for a die class Die: def init ( self, n ): self.nosides = n self.value = 1 def roll( self ): self.value = random.randrange( 1, self.nosides+1 ) def getvalue( self ): return self.value
47 A Die Class # Create 2 dice, one with 6 sides d1 = Die( 6 ) d2 = Die( 8 ) # Roll both dice d1.roll( ) d2.roll( ) Die. init (6) # display their value print( "Die 1: ", d1.getvalue() ) print( "Die 2: ", d2.getvalue() ) # libraries import random # a class for a die class Die: def init ( self, n ): self.nosides = n self.value = 1 def roll( self ): self.value = random.randrange( 1, self.nosides+1 ) def getvalue( self ): return self.value
48 A Die Class # libraries import random # a class for a die class Die: def init ( self, n ): self.nosides = n self.value = 1 reference to the object def roll( self ): self.value = random.randrange( 1, self.nosides+1 ) def getvalue( self ): return self.value
49 A Die Class # Create 2 dice, one with 6 sides d1 = Die( 6 ) d2 = Die( 8 ) # Roll both dice d1.roll( ) d2.roll( ) # display their value print( "Die 1: ", d1.getvalue() ) print( "Die 2: ", d2.getvalue() ) # libraries import random # a class for a die class Die: def init ( self, n ): self.nosides = n self.value = 1 def roll( self ): self.value = random.randrange( 1, self.nosides+1 ) def getvalue( self ): return self.value must be 1st param of all methods
50 A Die Class # libraries import random # Create 2 dice, one with 6 sides d1 = Die( 6 ) d2 = Die( 8 ) # Roll both dice d1.roll( ) d2.roll( ) roll(d1) roll(d2) # display their value print( "Die 1: ", d1.getvalue() ) print( "Die 2: ", d2.getvalue() ) # a class for a die class Die: def init ( self, n ): self.nosides = n self.value = 1 def roll( self ): self.value = random.randrange( 1, self.nosides+1 ) def getvalue( self ): return self.value
51 A Die Class # libraries import random # a class for a die class Die: def init ( self, n ): self.nosides = n self.value = 1 makes the variable a "member" of the object def roll( self ): self.value = random.randrange( 1, self.nosides+1 ) def getvalue( self ): return self.value
52 Playing dice
53 We stopped here last time
54 Homework Programs Great Organization!
55 Homework Programs No main() function. Not Documented
56 Homework Programs Nice Job!
57 From Now On
58 All Programs Submitted
59 Must Be Documented
60 Or Else!
61 Up to 1 Letter Grade Down, For the whole assignment if Documentation Missing
62 Min/Max Revisited who is associated with the largest number? Alex, 3 Max, 4 Sophia, 10 Lujun, 2 Maggie, 5 Photo credit:
63 Classes and Objects
64 A Die Class from dieclass import Die def main(): # Create 2 dice, one with 6 sides d1 = Die( 6 ) d2 = Die( 8 ) # Roll both dice d1.roll( ) d2.roll( ) # display their value print( "Die 1: ", d1.getvalue() ) print( "Die 2: ", d2.getvalue() ) main() # dieclass.py # Definition for a die class. import random # a class for a die class Die: def init ( self, n ): self.nosides = n self.value = 1 def roll( self ): self.value = random.randrange( 1, self.nosides+1 ) def getvalue( self ): return self.value playdice.py dieclass.py
65 Why Create a Die Class? Randint Could have Sufficed Modularity Details are hidden (Information hiding) The Die class can easily be enhanced/modified without having to change main program die with a bias history of rolls keeping track of statistics
66 Write a program that maintains a list of cat objects. Cats have a name, a breed, may or may not be vaccinated, and have an age expressed in years. Exercise Image credits: nicepixy.net
67 Examples Minou, 3, vac, stray Max, 1, not-vac, Burmese Gizmo, 2, vac, Bengal Garfield, 4, not-vac, Orange Tabby
68 Using Cat Objects # Example: using a cat object # Minou, 3, vac, stray cat1 = Cat( Minou, True, stray, 3 ) # Print if cat is vaccinated or not if cat1.isvaccinated(): print( cat1.getname(), is vaccinated ) else: print( cat1.getname(), is not vaccinated )
69 Wanted: A program that - outputs all the cats - outputs only the vaccinated cats - outputs the cats 2 or older
70 Good Methods To Start With When Creating a Class Constructor init () Inspector Methods getvalue() Mutator Methods roll() Default string representation str ()
71 We stopped here last time
72 Converting A String to a Boolean
73 Converting A String to a Boolean
74 Converting A String to a Boolean
75 Converting A String to a Boolean
76 Converting A String to a Boolean
77 Important Concepts: LOCAL vs. GLOBAL
78 What can you say about this program? Focus on the variable a
79 Local Variable What can you say about this program? Focus on the variable a
80 Local Variable Error! What can you say about this program? Focus on the variable a
81 Local Variable Error! Local Variable What can you say about this program? Focus on the variable a
82 What can you say about this new program? Focus on the variable a
83 30 30
84 Global Variable 30 30
85 What can you say about this third program? Focus on the variable a
86
87 Global Variable Local Variable
88 What can you say about this fourth program? Focus on the variable a
89
90 Review
91 Review Blueprint class def
92 Review Blueprint class def
93 Review Blueprint class def
94 Review Blueprint class def value
95 Review Blueprint class def value
96 Review Instantiation: Object is instance of a Class Blueprint class def member variable instance variable value Class method
97 Review: A Die Class # libraries import random # Create 2 dice, one with 6 sides d1 = Die( 6 ) d2 = Die( 8 ) # Roll both dice d1.roll( ) d2.roll( ) # display their value print( "Die 1: ", d1.getvalue() ) print( "Die 2: ", d2.getvalue() ) # a class for a die class Die: def init ( self, n ): self.nosides = n self.value = 1 def roll( self ): self.value = random.randrange( 1, self.nosides+1 ) def getvalue( self ): return self.value
98 Review: A Die Class WHY self.? # Create 2 dice, one with 6 sides d1 = Die( 6 ) d2 = Die( 8 ) # Roll both dice d1.roll( ) d2.roll( ) # display their value print( "Die 1: ", d1.getvalue() ) print( "Die 2: ", d2.getvalue() ) # libraries import random # a class for a die class Die: def init ( self, n ): self.nosides = n self.value = 1 def roll( self ): self.value = random.randrange( 1, self.nosides+1 ) def getvalue( self ): return self.value
99 Pair Programming in Lab 9 Review of Classes and Objects Cats, Cats, Cats Default string representation List of Cats Reading CSV Files of Cats Searching for a Cat in a List
100 Back to Cats
101 Using Cat Objects # Minou, 3, vaccinated, stray cat1 = Cat( Minou, True, stray, 3 ) if cat1.isvaccinated(): print( cat1.getname(), is vaccinated ) else: print( cat1.getname(), is not vaccinated )
102 Step 1: Implement the Class
103 Step 2: Create a List of Cats
104 Step 3: Read a CSV File of Cats
105 Step 4: Display Only Vaccinated Cats
106 Step 5: Search for the Youngest Cat
107 Looping through a list of objects Object-Oriented Graphics
108 Graphic Cars Moving Around
109 Car Geometry
110 e Demo T mo Time Demo Ti Time Demo Time Demo e Demo Time Demo Time emo Time Demo Time Demo Time Demo Time Demo Time Demo Time Demo Time D e Demo Time Demo Time Demo T Time D Demo Time!
111 Inspiration
112 Video 1
113 Video 2
114 Video 3
mith College Computer Science Lecture Notes CSC111 Week 7 Spring 2018 Dominique Thiébaut
mith College Computer Science Lecture Notes Week 7 Spring 2018 CSC111 Dominique Thiébaut dthiebaut@smith.edu Midterm Grades available later today (3/19/18) Outline A Second Look at Files Reading Files
More informationUniversity of Massachusetts Amherst, Electrical and Computer Engineering
University of Massachusetts Amherst, Electrical and Computer Engineering ECE 122 Midterm Exam 1 Makeup Answer key March 2, 2018 Instructions: Closed book, Calculators allowed; Duration:120 minutes; Write
More informationExample: Class MSDie Introduction to Graphs and NetworkX
Example: Class MSDie Introduction to Graphs and NetworkX Monday, March 30, 2009 1 Be careful whose random number generator you trust http://xkcd.com/221/ 2 1 Reminders Sample exam questions have been posted
More informationmith College Computer Science CSC231-Assembly Week #1 Fall 2018 Dominique Thiébaut
mith College Computer Science CSC231-Assembly Week #1 Fall 2018 Dominique Thiébaut dthiebaut@smith.edu This Week Last name: A-N > Lab Monday, Off Wednesday Last name: M-Z > Off Monday, Lab Wednesday Plan
More informationmith College Computer Science Week 8 CSC111 - Spring 2015 Dominique Thiébaut
mith College Computer Science Week 8 CSC111 - Spring 2015 Dominique Thiébaut dthiebaut@smith.edu Midterm Exams Returned Wed 3/26 1:00 p.m. FH356 ! Review Loops & Booleans (Chapter 8) For loops in context
More informationmith College Computer Science Week 10 CSC111 Spring 2015 Dominique Thiébaut
mith College Computer Science Week 10 CSC111 Spring 2015 Dominique Thiébaut dthiebaut@smith.edu Next Few Lectures Image Processing with Nested For-Loops Lists can be Used to Solve Many Problems (Chap.
More informationIntroduction to Computer Programming for Non-Majors
Introduction to Computer Programming for Non-Majors CSC 2301, Fall 2016 Chapter 10 Part 1 Instructor: Long Ma The Department of Computer Science Top-Down Design 2 In top-down design, a complex problem
More informationmith College CSC 111 Introduction to Computer Science Spring 2018 Week 2 Dominique Thiébaut
mith College Computer Science CSC 111 Introduction to Computer Science Spring 2018 Week 2 Dominique Thiébaut dthiebaut@smith.edu Outline Moodle Access Piazza Homework partners Loops + range() Input Programming
More informationmith College Computer Science CSC103 How Computers Work Week 7 Fall 2017 Dominique Thiébaut
mith College Computer Science CSC103 How Computers Work Week 7 Fall 2017 Dominique Thiébaut dthiebaut@smith.edu Important Review Does the animation leave a trace? Are the moving objects move without a
More informationWelcome to CSC148! Introduction to Computer Science
Welcome to CSC148! Introduction to Computer Science Amir H. Chinaei, Summer 2016 ahchinaei@cs.toronto.edu http://www.cs.toronto.edu/~ahchinaei/ Office hours: R 10 BA4222 Today Course Outline (bird s-eye
More informationmith College Computer Science CSC231 Assembly Week #13 Fall 2017 Dominique Thiébaut
mith College Computer Science CSC21 Assembly Week #1 Fall 2017 Dominique Thiébaut dthiebaut@smith.edu for n in 0 1 2 5 ; do echo "n =$n"./hw7b $n echo "" done Pascal Triangle n =0 n =1 1 n =2 1 0 1 1 n
More informationmith College Computer Science CSC231 Assembly Week #12 Thanksgiving 2017 Dominique Thiébaut
mith College Computer Science CSC231 Assembly Week #12 Thanksgiving 2017 Dominique Thiébaut dthiebaut@smith.edu ;;; FUNCTION SIDE function: ebp ;save old ebp ebp, esp ;make ebp point ;to stack frame Summary
More informationmith College Computer Science Digitizing Smith A Liberal Arts Module Week 11 CSC111 - Fall 2015 Dominique Thiébaut
mith College Computer Science Digitizing Smith A Liberal Arts Module Week 11 CSC111 - Fall 2015 Dominique Thiébaut dthiebaut@smith.edu Summary Video Lecture by Prof. Helene Visentin LAM Project in 2 phases
More informationmith College Computer Science Week 12 CSC111 Spring 2018 Dominique Thiébaut
mith College Computer Science Week 12 CSC111 Spring 2018 Dominique Thiébaut dthiebaut@smith.edu http://www.science.smith.edu/dftwiki/index.php/ Nice_Wrapping_Paper... Polymorphism Dictionaries & Recursion
More information15-110: Principles of Computing, Spring 2018
5-: Principles of Computing, Spring 28 Problem Set 8 (PS8) Due: Friday, March 3 by 2:3PM via Gradescope Hand-in HANDIN INSTRUCTIONS Download a copy of this PDF file. You have two ways to fill in your answers:.
More informationProfessor Hugh C. Lauer CS-1004 Introduction to Programming for Non-Majors
Objects (again) Professor Hugh C. Lauer CS-1004 Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An Introduction to Computer Science, 2 nd edition, by John
More informationmith College Computer Science CSC103 How Computers Work Week 6 Fall 2017 Dominique Thiébaut
mith College Computer Science CSC103 How Computers Work Week 6 Fall 2017 Dominique Thiébaut dthiebaut@smith.edu Ben Fry on Processing... http://www.youtube.com/watch?&v=z-g-cwdnudu An Example Mouse 2D
More informationCS108 Lecture 16: User Defined Classes. Overview/Questions
CS108 Lecture 16: User Defined Classes Aaron Stevens 23 February 2009 1 Overview/Questions Review: the function of functions Thinking about program structure Review: objects and classes How do we design
More informationmith College Computer Science Week 7 CSC111 Fall 2015 Dominique Thiébaut
mith College Computer Science Week 7 CSC111 Fall 2015 Dominique Thiébaut dthiebaut@smith.edu Dynamic Web Page Example IF Statements & Boolean Expression An Application: Generating Dynamic Web Pages Introduction
More informationObject Oriented Programming
Object Oriented Programming Objectives To review the concepts and terminology of object-oriented programming To discuss some features of objectoriented design 1-2 Review: Objects In Java and other Object-Oriented
More informationAssignment 1 due Monday at 11:59pm
Assignment 1 due Monday at 11:59pm The heart of Object-Oriented Programming (Now it gets interesting!) Reading for next lecture is Ch. 7 Focus on 7.1, 7.2, and 7.6 Read the rest of Ch. 7 for class after
More informationCIS 162 Project 4 Farkle (a dice game)
CIS 162 Project 4 Farkle (a dice game) Due Date at the start of class on Monday, 3 December (be prepared for quick demo and zybook test) Before Starting the Project Read chapter 10 (ArrayList) and 13 (arrays)
More informationObject Oriented Programming
Object Oriented Programming Objectives To review the concepts and terminology of object-oriented programming To discuss some features of objectoriented design 1-2 Review: Objects In Java and other Object-Oriented
More informationPrinciples of Computer Science I
Principles of Computer Science I Prof. Nadeem Abdul Hamid CSC 120A - Fall 2004 Lecture Unit 7 Review Chapter 4 Boolean data type and operators (&&,,) Selection control flow structure if, if-else, nested
More informationPractice Question. Omar Khan / Atif Alvi. October 10, 2016
Practice Question Omar Khan / Atif Alvi October 10, 2016 1 Chapter 1 Loops 1.1 While Loop Iterating through a string 1. Print the first 10 integers 1 i = 0 2 n = 10 3 while i
More informationmith College Computer Science Week 13 CSC111 Fall 2015 (Lab 12, Homework 12) Dominique Thiébaut
mith College Computer Science Week 13 CSC111 Fall 2015 (Lab 12, Homework 12) Dominique Thiébaut dthiebaut@smith.edu This Week: Two Concepts Lists of Lists Class Inheritance Lists of Lists (Chapter 11 Designing
More informationLAB 4.1 Relational Operators and the if Statement
LAB 4.1 Relational Operators and the if Statement // This program tests whether or not an initialized value of num2 // is equal to a value of num1 input by the user. int main( ) int num1, // num1 is not
More informationCSC 222: Object-Oriented Programming. Fall 2015
CSC 222: Object-Oriented Programming Fall 2015 Understanding class definitions class structure fields, constructors, methods parameters assignment statements conditional statements local variables 1 Looking
More informationProgramming for Engineers in Python. Autumn
Programming for Engineers in Python Autumn 2011-12 Plan Administration: Course site Homework submission guidelines Working environment Python: Variables Editor vs. shell Homework 0 Python Cont. Conditional
More informationUNIT 6. Functions and Structured Programming
UNIT 6 Functions and Structured Programming DAY 1 What is a Function? What is Structured Programming? I can.. Divide a large program into small problems. Write a Python program as a function Planning a
More informationCS61BL. Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling
CS61BL Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling About me Name: Edwin Liao Email: edliao@berkeley.edu Office hours: Thursday 3pm - 5pm Friday 11am - 1pm 611 Soda Or by
More informationDownloaded 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 informationCpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input
CpSc Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input Overview For this lab, you will use: one or more of the conditional statements explained below scanf() or fscanf() to read
More informationENGR 102 Engineering Lab I - Computation
ENGR 102 Engineering Lab I - Computation Learning Objectives by Week 1 ENGR 102 Engineering Lab I Computation 2 Credits 2. Introduction to the design and development of computer applications for engineers;
More informationCMSC 201 Fall 2016 Lab 09 Advanced Debugging
CMSC 201 Fall 2016 Lab 09 Advanced Debugging Assignment: Lab 09 Advanced Debugging Due Date: During discussion Value: 10 points Part 1: Introduction to Errors Throughout this semester, we have been working
More informationCSC148 Intro. to Computer Science
CSC148 Intro. to Computer Science Lecture 2: designing classes, special methods, managing attributes; intro composition, inheritance Amir H. Chinaei, Summer 2016 Office Hours: R 10 12 BA4222 csc148ta@cdf.toronto.edu
More informationmith College Computer Science CSC270 Spring 2016 Circuits and Systems Lecture Notes, Week 11 Dominique Thiébaut
mith College Computer Science CSC270 Spring 2016 Circuits and Systems Lecture Notes, Week 11 Dominique Thiébaut dthiebaut@smithedu Outline A Few Words about HW 8 Finish the Input Port Lab! Revisiting Homework
More informationCourse Outline. Introduction to java
Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.
More informationCS 251 Intermediate Programming Methods and Classes
CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationProgramming for Engineers in Python. Recitation 1
Programming for Engineers in Python Recitation 1 Plan Administration: Course site Homework submission guidelines Working environment Python: Variables Editor vs. shell Homework 0 Python Cont. Conditional
More informationCSI33 Data Structures
Outline Department of Mathematics and Computer Science Bronx Community College August 29, 2018 Outline Outline 1 Chapter 2: Data Abstraction Outline Chapter 2: Data Abstraction 1 Chapter 2: Data Abstraction
More informationmith College Computer Science CSC352 Week #7 Spring 2017 Introduction to C Dominique Thiébaut
mith College CSC352 Week #7 Spring 2017 Introduction to C Dominique Thiébaut dthiebaut@smith.edu Learning C in 2 Hours D. Thiebaut Dennis Ritchie 1969 to 1973 AT&T Bell Labs Close to Assembly Unix Standard
More informationA453 Task 1: Analysis: Problem: Solution:
: Analysis: Problem: The problem I need to solve is that I need to design, code, and test a program that simulates a dice throw of a 4, 6, or 12 sided die and outputs the result before repeating the process
More informationmith College Computer Science CSC231-Assembly Fall 2017 Week #2 Dominique Thiébaut
mith College Computer Science CSC231-Assembly Fall 2017 Week #2 Dominique Thiébaut dthiebaut@smith.edu Outline Labs: emacs, assembly Assembly + Linking Process Object files DB directive: Everything is
More informationCS 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 informationCMSC201 Computer Science I for Majors
CMSC201 Computer Science I for Majors Lecture 25 Classes All materials copyright UMBC and Dr. Katherine Gibson unless otherwise noted Run time Last Class We Covered Run time of different algorithms Selection,
More informationBasic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2
Basic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2 Ziad Matni, Ph.D. Dept. of Computer Science, UCSB Your Instructor Your instructor: Ziad Matni, Ph.D(zee-ahd
More informationCSC231 C Tutorial Fall 2018 Introduction to C
mith College CSC231 C Tutorial Fall 2018 Introduction to C Dominique Thiébaut dthiebaut@smith.edu Learning C in 4 Installments! Dennis Ritchie 1969 to 1973 AT&T Bell Labs Close to Assembly Unix Standard
More informationmith College Computer Science CSC231 Bash Labs Week #10, 11, 12 Spring 2017 Introduction to C Dominique Thiébaut
mith College CSC231 Bash Labs Week #10, 11, 12 Spring 2017 Introduction to C Dominique Thiébaut dthiebaut@smith.edu Learning C in 4 Hours! D. Thiebaut Dennis Ritchie 1969 to 1973 AT&T Bell Labs Close to
More informationCSC 015: FUNDAMENTALS OF COMPUTER SCIENCE I
CSC 015: FUNDAMENTALS OF COMPUTER SCIENCE I Lecture 1: Class Introduction DR. BO TANG ASSISTANT PROFESSOR HOFSTRA UNIVERSITY 1 9/7/16 CSC15 - Python OUTLINE What is Computer Science? What is this Class
More informationCS 1301 Exam 1 Answers Fall 2009
Page 1/6 CS 1301 Fall 2009 Exam 1 Your Name: I commit to uphold the ideals of honor and integrity by refusing to betray the trust bestowed upon me as a member of the Georgia Tech community. CS 1301 Exam
More informationCSC 222: Object-Oriented Programming. Fall 2017
CSC 222: Object-Oriented Programming Fall 2017 Understanding class definitions class structure fields, constructors, methods parameters shorthand assignments local variables final-static fields, static
More informationLECTURE 4 Python Basics Part 3
LECTURE 4 Python Basics Part 3 INPUT We ve already seen two useful functions for grabbing input from a user: raw_input() Asks the user for a string of input, and returns the string. If you provide an argument,
More informationWhat we already know. more of what we know. results, searching for "This" 6/21/2017. chapter 14
What we already know chapter 14 Files and Exceptions II Files are bytes on disk. Two types, text and binary (we are working with text) open creates a connection between the disk contents and the program
More informationPython review. 1 Python basics. References. CS 234 Naomi Nishimura
Python review CS 234 Naomi Nishimura The sections below indicate Python material, the degree to which it will be used in the course, and various resources you can use to review the material. You are not
More informationThe Big Python Guide
The Big Python Guide Big Python Guide - Page 1 Contents Input, Output and Variables........ 3 Selection (if...then)......... 4 Iteration (for loops)......... 5 Iteration (while loops)........ 6 String
More informationIntroduction to Classes and Objects. David Greenstein Monta Vista High School
Introduction to Classes and Objects David Greenstein Monta Vista High School Client Class A client class is one that constructs and uses objects of another class. B is a client of A public class A private
More informationCSC148: Week 1
CSC148: Week 1 http://www.cdf.utoronto.ca/~csc148h/summer/ Sophia Huynh Summer 2018 1 Outline Introduction Object-Oriented Design 2 Your instructor Sophia Huynh Master's Student Undergrad was done at UofT
More informationPython 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 informationAl al-bayt University Prince Hussein Bin Abdullah College for Information Technology Computer Science Department
Al al-bayt University Prince Hussein Bin Abdullah College for Information Technology Computer Science Department 0901212 Python Programming 1 st Semester 2014/2015 Course Catalog This course introduces
More informationCSC148 Recipe for Designing Classes
Part 1: Define the API for the class CSC148 Recipe for Designing Classes Download the sample code here: https://www.teach.cs.toronto.edu/~csc148h/fall/lectures/object-oriented-programming/common/course.
More informationmith College Computer Science CSC111 Week 8 Spring 2018 Dominique Thiébaut
mith College Computer Science CSC111 Week 8 Spring 2018 Dominique Thiébaut dthiebaut@smith.edu mith Hac Smith Hack Smi k Smith Hack Smith Ha ack Smith Hack Smith Hack Smit ack Smith Hack Smith Hack Smith
More informationCompSci 125 Lecture 02
Assignments CompSci 125 Lecture 02 Java and Java Programming with Eclipse! Homework:! http://coen.boisestate.edu/jconrad/compsci-125-homework! hw1 due Jan 28 (MW), 29 (TuTh)! Programming:! http://coen.boisestate.edu/jconrad/cs125-programming-assignments!
More informationLecture 21. Topics: Chapter 10. Defining Classes 10.4 Data processing with class 10.5 Objects and encapsulation 10.6 Widgets
Lecture 21 Topics: Chapter 10. Defining Classes 10.4 Data processing with class 10.5 Objects and encapsulation 10.6 Widgets 1 10.4 Data processing with class Example with dice from the previous meeting
More informationCS 251 Intermediate Programming Methods and More
CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationCSC 1051 Algorithms and Data Structures I. Final Examination May 2, Name:
CSC 1051 Algorithms and Data Structures I Final Examination May 2, 2015 Name: Question Value 1 10 Score 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 20 TOTAL 100 Please answer questions in the spaces provided.
More informationLecture 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 informationOutline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types
Data Types Declarations and Initializations Larry Caretto Computer Science 16 Computing in Engineering and Science February 7, 25 Outline Review last week Meaning of data types Integer data types have
More informationFunctions and Decomposition
Unit 4 Functions and Decomposition Learning Outcomes Design and implement functions to carry out a particular task. Begin to evaluate when it is necessary to split some work into functions. Locate the
More informationLab and Assignment Activity
Lab and Assignment Activity 1 Introduction Sometime ago, a Titanic dataset was released to the general public. This file is given to you as titanic_data.csv. This data is in text format and contains 12
More informationCSC148 Intro. to Computer Science
CSC148 Intro. to Computer Science Lecture 4: Container implementation, Unit Test, Balanced Parentheses, Intro to Linked Lists Amir H. Chinaei, Summer 2016 Office Hours: R 10-12 BA4222 ahchinaei@cs.toronto.edu
More informationLecture 7 Objects and Classes
Lecture 7 Objects and Classes An Introduction to Data Abstraction MIT AITI June 13th, 2005 1 What do we know so far? Primitives: int, double, boolean, String* Variables: Stores values of one type. Arrays:
More informationCS 1301 Exam 1 Fall 2009
Page 1/6 CS 1301 Fall 2009 Exam 1 Your Name: I commit to uphold the ideals of honor and integrity by refusing to betray the trust bestowed upon me as a member of the Georgia Tech community. CS 1301 Exam
More informationMIT AITI Python Software Development
MIT AITI Python Software Development PYTHON L02: In this lab we practice all that we have learned on variables (lack of types), naming conventions, numeric types and coercion, strings, booleans, operator
More informationQuestion 1. Part (a) Simple Syntax [1 mark] Circle add_ints(), because it is missing arguments to the function call. Part (b) Simple Syntax [1 mark]
Note to Students: This file contains sample solutions to the term test together with the marking scheme and comments for each question. Please read the solutions and the marking schemes and comments carefully.
More informationIntroduction 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 informationmith College Computer Science CSC231 Assembly Week #10 Fall 2017 Dominique Thiébaut
mith College Computer Science CSC231 Assembly Week #10 Fall 2017 Dominique Thiébaut dthiebaut@smith.edu 2 Videos to Start With https://www.youtube.com/watch?v=fdmzngwchdk https://www.youtube.com/watch?v=k2iz1qsx4cm
More informationCME 193: Introduction to Scientific Python Lecture 4: File I/O and Classes
CME 193: Introduction to Scientific Python Lecture 4: File I/O and Classes Sven Schmit stanford.edu/~schmit/cme193 4: File I/O and Classes 4-1 Feedback form Please take a moment to fill out feedback form
More informationCSC-105 Exam #1 October 10, 2013
CSC-105 Exam #1 October 10, 2013 Name Questions are weighted as indicated. Show your work and state your assumptions for partial credit consideration. Unless explicitly stated, there are NO intended errors
More informationDefining Classes and Methods. Objectives. Objectives 6/27/2014. Chapter 5
Defining Classes and Methods Chapter 5 Objectives Describe concepts of class, class object Create class objects Define a Java class, its methods Describe use of parameters in a method Use modifiers public,
More informationUNIT 9A Randomness in Computation: Random Number Generators
UNIT 9A Randomness in Computation: Random Number Generators 1 Last Unit Computer organization: what s under the hood 3 This Unit Random number generation Using pseudorandom numbers 4 Overview The concept
More informationChapter 4: Writing Classes
Chapter 4: Writing Classes Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Writing Classes We've been using predefined classes. Now we will learn to write our own
More informationCS 11 Project #6 Due THURSDAY, December 7 th, 11:59pm. Classes and Exceptions Background: Classes allow us to define new types for Python. We can first think of a class as defining a new container instead
More informationObject Oriented Programming
Classes and Objects Object Oriented Programming Represent self-contained things using classes. A class consists of: Data (stored in variables) Operations on that data (written as functions) Represent individual
More informationIntro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming
Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals
More informationData Structures (list, dictionary, tuples, sets, strings)
Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access
More informationMidterms Save the Dates!
University of British Columbia CPSC 111, Intro to Computation Alan J. Hu if Statements Designing Classes Abstraction and Encapsulation Readings This Week s Reading: Review Ch 1-4 (that were previously
More informationLecture 7: Objects (Chapter 15) CS 1110 Introduction to Computing Using Python
htt://www.cs.cornell.edu/courses/cs1110/2018s Lecture 7: Objects (Chater 15) CS 1110 Introduction to Comuting Using Python [E. Andersen, A. Bracy, D. Gries, L. Lee, S. Marschner, C. Van Loan, W. White]
More information4.2 Function definitions the basics
4.2. FUNCTION DEFINITIONS THE BASICS 89 4.2 Function definitions the basics There are three questions you must answer before you can write a function definition: What will the function do? What inputs
More informationChapter 5 Functions (Part 2) Hong Sun COSC 1436 Fall, 2017 Oct 18, 2017
Chapter 5 Functions (Part 2) Hong Sun COSC 1436 Fall, 2017 Oct 18, 2017 Defining and Calling a Void Function Function Name Roles: python requires that you follow the same rules that you follow when naming
More informationObjectives. Defining Classes and Methods. Objectives. Class and Method Definitions: Outline 7/13/09
Objectives Walter Savitch Frank M. Carrano Defining Classes and Methods Chapter 5 Describe concepts of class, class object Create class objects Define a Java class, its methods Describe use of parameters
More informationPart III Appendices 165
Part III Appendices 165 Appendix A Technical Instructions Learning Outcomes This material will help you learn how to use the software you need to do your work in this course. You won t be tested on it.
More information61A Lecture 16. Wednesday, October 5
61A Lecture 16 Wednesday, October 5 Policy Changes Based on the Survey Homework can now be completed in pairs, if you wish. Every individual should still submit his/her own homework Please write your partner's
More informationReview Chapter 6 in Bravaco. Short Answers 1. This type of method does not return a value. a. null b. void c. empty d. anonymous
Assignment 3 Methods Review CSC 123 Fall 2018 Notes: All homework must be submitted via e-mail. All parts of assignment must be submitted in a single e-mail with multiple attachments when required. Notes:
More informationCSCE 110: Programming I
CSCE 110: Programming I Sample Questions for Exam #1 February 17, 2013 Below are sample questions to help you prepare for Exam #1. Make sure you can solve all of these problems by hand. For most of the
More informationCredit: The lecture slides are created based on previous lecture slides by Dan Zingaro.
CSC148 2018 Here 1 Credit: The lecture slides are created based on previous lecture slides by Dan Zingaro. 2 Larry Zhang Office: DH-3042 Email: ylzhang@cs.toronto.edu 3 The teaching team Dan Zingaro: LEC0103
More informationIntroduction. We've seen Python useful for. This lecture discusses Object Oriented Programming. Simple scripts Module design
Introduction We've seen Python useful for Simple scripts Module design This lecture discusses Object Oriented Programming Better program design Better modularization What is an object? An object is an
More informationThis homework has an opportunity for substantial extra credit, which is described at the end of this document.
CS 2316 Pair Homework Box Packer Due: Tuesday, June 17th, before 11:55 PM Out of 100 points Files to submit: 1. boxpacker.py For Help: - TA Helpdesk Schedule posted on class website. - Email TA's or use
More informationIntroduction to Computer Science Unit 4B. Programs: Classes and Objects
Introduction to Computer Science Unit 4B. Programs: Classes and Objects This section must be updated to work with repl.it 1. Copy the Box class and compile it. But you won t be able to run it because it
More informationCS 31: Intro to Systems C Programming. Kevin Webb Swarthmore College September 13, 2018
CS 31: Intro to Systems C Programming Kevin Webb Swarthmore College September 13, 2018 Reading Quiz Agenda Basics of C programming Comments, variables, print statements, loops, conditionals, etc. NOT the
More information