predator-prey simulations

Size: px
Start display at page:

Download "predator-prey simulations"

Transcription

1 predator-prey simulations 1 Hopping Frogs an object oriented model of a frog animating frogs with threads 2 Frogs on Canvas a GUI for hopping frogs stopping and restarting threads 3 Flying Birds an object oriented model of a bird defining a pond of frogs giving birds access to the swamp MCS 260 Lecture 36 Introduction to Computer Science Jan Verschelde, 11 April 2016 Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

2 predator-prey simulations 1 Hopping Frogs an object oriented model of a frog animating frogs with threads 2 Frogs on Canvas a GUI for hopping frogs stopping and restarting threads 3 Flying Birds an object oriented model of a bird defining a pond of frogs giving birds access to the swamp Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

3 Modeling Frogs in object oriented fashion Imagine frogs happily hopping around in a pond... Functional attributes in the class Frog: hop : wait a bit and hop to next spot, run : do some fixed number of hops. Data attributes in the class Frog: position : coordinates (x, y) for its location, hop limit : number of hops done by the frog, step size : largest step size a frog can do, rest time : time while frog rests between steps. Adding some randomness makes it more interesting. Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

4 The Class Diagram In the Unified Modeling Language (UML), we draw Frog position hop limit step size rest time hop run Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

5 script class_frog.py from time import sleep from random import randint class Frog(object): Object oriented model of a frog. def init (self, n, x, y, h, d, m): A frog with name n at (x,y) makes m hops of size at most h, resting at most d seconds. self.name = n self.position = (x, y) self.hop_limit = m self.step_size = h self.rest_time = d Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

6 functional attributes def hop(self): The frog waits a bit before hopping. name = self.name pos = self.position rnd = randint(0, self.rest_time) print(name + at + str(pos) \ + waits + str(rnd) + seconds ) sleep(rnd) hopstep = self.step_size (xps, yps) = self.position nxp = xps + randint(-1, +1)*hopstep nyp = yps + randint(-1, +1)*hopstep self.position = (nxp, nyp) print(name + hops to + str((nxp, nyp))) Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

7 functions run and main def run(self): The frog does as many hops as the value set by self.hop_limit. while self.hop_limit > 0: self.hop() self.hop_limit = self.hop_limit - 1 def main(): Kermit our hero hops around! print( Kermit the frog is born... ) k = Frog( Kermit, +10, +10, 5, 2, 4) print( Kermit starts hopping... ) k.run() Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

8 predator-prey simulations 1 Hopping Frogs an object oriented model of a frog animating frogs with threads 2 Frogs on Canvas a GUI for hopping frogs stopping and restarting threads 3 Flying Birds an object oriented model of a bird defining a pond of frogs giving birds access to the swamp Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

9 multithreading in Python many frogs hop independently Most processors have multiple cores, allowing for parallel execution in real time, speeding up calculations. Even on one core, the operating system runs many threads. Python provides the Thread class in the threading module. In addition to the init we override the definition of run when defining a class, inheriting from Thread. For t, an instance of the inherited Thread class: t.start() executes the defined run method. multiple threads run simultaneously Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

10 script class_threadfrog.py from threading import Thread from class_frog import Frog class ThreadFrog(Thread, Frog): Exports hopping frogs as threads. def init (self, n, x, y, h, d, m): A frog with name n at (x,y) makes m hops of size at most h, resting at most d seconds. Thread. init (self, name=n) Frog. init (self, n, x, y, h, d, m) We inherit from Thread and Frog. Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

11 script class_threadfrog.py continued... def run(self): The frog does as many moves as the value set by self.moves. while self.hop_limit > 0: self.hop() self.hop_limit = self.hop_limit - 1 The hop() method is defined in class_frog.py, as a method of the class Frog. Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

12 the main() in class_script def main(): Runs a simple test on hopping frogs. print( creating two frogs: a and b ) ann = ThreadFrog( a, +10, +10, 5, 2, 4) bob = ThreadFrog( b, -10, -10, 15, 5, 3) print( starting the hopping... ) ann.start() bob.start() print( waiting for frogs to finish... ) ann.join() bob.join() if name == " main ": main() Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

13 predator-prey simulations 1 Hopping Frogs an object oriented model of a frog animating frogs with threads 2 Frogs on Canvas a GUI for hopping frogs stopping and restarting threads 3 Flying Birds an object oriented model of a bird defining a pond of frogs giving birds access to the swamp Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

14 Frogs on Canvas a GUI for hopping frogs In our GUI, the canvas will be the pond. The user can place frogs in the pond with the mouse. Three buttons: start : to start animating the hopping of frogs, stop : to stop the animation for adding frogs, clear : to clear the canvas after killing frogs. The names of the frogs are letters a, b, c,... used as text to mark the frogs on canvas. Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

15 running the GUI Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

16 data attributes from tkinter import Tk, StringVar, Label, Canvas from tkinter import Button, W, E, ALL from class_threadfrog import ThreadFrog class DrawFrogs(object): GUI to hopping frogs on canvas def init (self, wdw, d): Defines a square canvas of d pixels, label, start, stop, and clear buttons. wdw.title("drawing hopping frogs") self.frogs = [] self.gohop = False self.dim = d self.msg = StringVar() Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

17 label, canvas, bindings, buttons self.msg.set("put mouse inside box to place frogs") self.lab = Label(wdw, textvariable=self.msg) self.lab.grid(row=0, column=0, columnspan=3) self.cnv = Canvas(wdw, width=d, height=d, bg= white ) self.cnv.grid(row=1, columnspan=3) self.cnv.bind("<button-1>", self.button_pressed) self.cnv.bind("<buttonrelease-1>", self.button_released) self.bt0 = Button(wdw, text= start, command=self.start) self.bt0.grid(row=2, column=0, sticky=w+e) self.bt1 = Button(wdw, text= stop, command=self.stop) self.bt1.grid(row=2, column=1, sticky=w+e) self.bt2 = Button(wdw, text= clear, command=self.clear) self.bt2.grid(row=2, column=2, sticky=w+e) Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

18 defining mouse bindings def button_pressed(self, event): Displays coordinates of button pressed. self.msg.set("currently at [ " + \ str(event.x) + ", " + str(event.y) + " ]" +\ " release to place frog") def button_released(self, event): At release of button, a frog is created at the current location of the mouse pointer. self.msg.set("placed frog at [ " + \ str(event.x) + ", " + str(event.y) + " ]") self.new_frog(event.x, event.y) self.draw_frogs() Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

19 anewfrog def new_frog(self, xps, yps): Defines a new frog with coordinates given in (xps, yps) via the mouse. nbr = len(self.frogs) name = chr(ord( a )+nbr) frog = ThreadFrog(name, xps, yps, 20, 5, 100) self.frogs.append(frog) Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

20 drawing frogs def draw_frogs(self): Draws frogs on canvas, eventually after fixing their coordinates. dim = self.dim for frog in self.frogs: (xps, yps) = frog.position name = frog.getname() self.cnv.delete(name) if xps < 0: xps = dim - xps if yps < 0: yps = dim - yps if xps > dim: xps = xps - dim if yps > dim: yps = yps - dim frog.position = (xps, yps) self.cnv.create_text(xps, yps, text=name, tags=name) Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

21 starting the animation def start(self): Starts all frogs and the animation. self.gohop = True for frog in self.frogs: frog.start() while self.gohop: self.draw_frogs() self.cnv.after(10) self.cnv.update() Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

22 predator-prey simulations 1 Hopping Frogs an object oriented model of a frog animating frogs with threads 2 Frogs on Canvas a GUI for hopping frogs stopping and restarting threads 3 Flying Birds an object oriented model of a bird defining a pond of frogs giving birds access to the swamp Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

23 stopping an animation We cannot halt threads, but we kill frogs by setting their hop_limit to zero. Setting hop_limit stops the loop in run and then we create a new frog with the same data. def clear(self): Deletes all frogs from canvas. print( killing all frogs... ) for frog in self.frogs: frog.hop_limit = 0 while len(self.frogs) > 0: self.frogs.pop(0) self.cnv.delete(all) # cleaning canvas Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

24 stopping and restarting def stop(self): Sets hop limits of frogs to zero. self.gohop = False print( setting moves of frogs to zero... ) for frog in self.frogs: frog.hop_limit = 0 print( resetting all frogs... ) newfrogs = [] while len(self.frogs) > 0: frog = self.frogs.pop(0) pos = frog.position step = frog.step_size rest = frog.rest_time newf = ThreadFrog(frog.getName(), pos[0], pos[1], \ step, rest, 100) newfrogs.append(newf) self.frogs = newfrogs Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

25 predator-prey simulations 1 Hopping Frogs an object oriented model of a frog animating frogs with threads 2 Frogs on Canvas a GUI for hopping frogs stopping and restarting threads 3 Flying Birds an object oriented model of a bird defining a pond of frogs giving birds access to the swamp Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

26 Modeling Birds in object oriented fashion Birds fly over the pond, preying on frogs. Functional attributes for an object of the class Bird: fly : fly in some direction and then land, eat : eat closest frog within a certain radius, run :dofly() and eat() a fixed number of times. Data attributes in the class Bird: position : coordinates (x, y) for its location, direction : tuple (d x, d y ) defines flying direction, fly range : how many times a bird flies and lands, land time : time spent on land between air trips, eat radius : distance for closest frog to be eaten. Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

27 The Class Diagram In the Unified Modeling Language (UML), we draw Bird position direction fly range land time eat radius fly eat run Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

28 script flying_birds.py class Bird(Thread): Exports flying birds as threads. def init (self, n, p, d, m, s, r): A bird with name n at position p flies m times in the direction d, spending at most s seconds on land, eating frogs within radius r. Thread. init (self, name=n) self.position = p self.direction = d self.fly_range = m self.land_time = s self.eat_radius = r Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

29 birds fly def fly(self): The bird waits a bit before flying. name = self.getname() pos = self.position tsec = randint(0, self.land_time) print(name + at + str(pos) \ + lands + str(tsec) + seconds ) sleep(tsec/2) self.eat() sleep(tsec/2) (xps, yps) = self.position nxps = xps + self.direction[0] nyps = yps + self.direction[1] self.position = (nxps, nyps) print(name + flies to + str((nxps, nyps))) Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

30 predator-prey simulations 1 Hopping Frogs an object oriented model of a frog animating frogs with threads 2 Frogs on Canvas a GUI for hopping frogs stopping and restarting threads 3 Flying Birds an object oriented model of a bird defining a pond of frogs giving birds access to the swamp Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

31 finding the closest frog To define the eat() method of the class Bird, we need to compute the closest frog. FrogPond frogs nearest_frog Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

32 script frog_pond.py from math import sqrt from class_threadfrog import ThreadFrog class FrogPond(object): A pond keeps the frogs and allows to locate the frogs for predators. def init (self, F): F is a list of frogs, which may be empty at first. self.frogs = F Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

33 computing the distance we indicate a method without def distance(pnt, qnt): Returns the distance between points pnt and qnt. sqrdif = (pnt[0] - qnt[0])**2 + (pnt[1] - qnt[1])**2 return sqrt(sqrdif) The method is then called as FrogPond.distance(). A static method is similar to a class wide data attribute. Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

34 computing the nearest frog def nearest_frog(self, pos): On input in pos is a tuple (x, y) with numerical coordinates in the plane. Returns (-1, None, -1) for an empty pond, or the tuple (d, f, i) where d is the distance of pos to the nearest frog at position i in the list of frogs. if len(self.frogs) == 0: return (-1, None, -1) else: k = 0 mindis = FrogPond.distance(self.frogs[k].position, pos) for i in range(1, len(self.frogs)): dis = FrogPond.distance(self.frogs[i].position, pos) if dis < mindis: (k, mindis) = (i, dis) return (mindis, self.frogs[k], k) Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

35 testing the class def main(): Runs a test on the FrogPond class. print( swamp with two frogs: a and b ) ann = ThreadFrog( a, +10, +10, 5, 2, 4) bob = ThreadFrog( b, -10, -10, 15, 5, 3) swamp = FrogPond([ann, bob]) while True: posraw = input("give a tuple of coordinates : ") pos = eval(posraw) near = swamp.nearest_frog(pos) if near[0]!= -1: print( nearest frog to, pos, is, \ near[1].getname(), at distance, \ near[0], at position, near[2]) ans = input("more locations? (y/n) ") if ans!= y : break Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

36 predator-prey simulations 1 Hopping Frogs an object oriented model of a frog animating frogs with threads 2 Frogs on Canvas a GUI for hopping frogs stopping and restarting threads 3 Flying Birds an object oriented model of a bird defining a pond of frogs giving birds access to the swamp Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

37 at start of flying_birds.py from class_threadfrog import ThreadFrog from frog_pond import FrogPond print( swamp with four frogs ) ANN = ThreadFrog( ann, +10, +10, 2, 5, 20) BOB = ThreadFrog( bob, +10, -10, 2, 5, 20) CINDY = ThreadFrog( cindy, -10, +10, 2, 5, 20) DAVE = ThreadFrog( dave, -10, -10, 2, 5, 20) SWAMP = FrogPond([ANN, BOB, CINDY, DAVE]) class Bird(Thread): Exports flying birds as threads. Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

38 method eat() def eat(self): Finds closest frog to the bird and eats it if within its radius. name = self.getname() prey = SWAMP.nearest_frog(self.position) if prey[0]!= -1: prn = prey[1].getname() spr = nearest frog to + name \ + is + prn \ + at distance + ( %.2f % prey[0]) if prey[0] > self.eat_radius: print(spr) else: print(spr + => + prn + gobbled up ) prey[1].hop_limit = 0 del SWAMP.frogs[prey[2]] Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

39 overriding the run def run(self): The bird flies as many times as the value set by self.fly_range. while self.fly_range > 0: self.fly() self.fly_range = self.fly_range - 1 Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

40 testing the simulation We have a swamp with four frogs, initially placed as below: c a d b and two birds flying into the pond, with directions drawn by arrows above. As they lie straight in the path of the birds, frogs b and d are easy preys, while a and c may hop away, escaping the birds. Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

41 themainprogram def main(): Runs a simple test on flying birds. print( creating two birds: A and B ) (apos, adir) = ((-15, -15), (+1, +1)) (bpos, bdir) = ((+15, -15), (-1, +1)) apred = Bird( A, apos, adir, 30, 4, 5) bpred = Bird( B, bpos, bdir, 30, 4, 5) print( frogs start life in swamp... ) for frog in SWAMP.frogs: frog.start() print( birds start to fly... ) apred.start() bpred.start() apred.join() bpred.join() Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

42 Three Classes ThreadFrog position hop limit step size rest time hop run FrogPond frogs nearest_frog Bird position direction fly range land time eat radius fly eat run The class FrogPond depends on the class ThreadFrog. The eat() method in Bird depends on ThreadFrog and on an instance of FrogPond. Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

43 Summary and Assignments Read chapter 11 of Python Programming. Assignments: 1 Extend the Frog class with a method breed(). When two frogs are within a certain distance from each other, new frogs are born. 2 Adjust the direction of the bird in the eat() method so that the bird flies towards the closest frog. 3 Change the class Bird so the simulation runs from a script not in the same file as the definition of the class. 4 Add flying birds to the GUI to place frogs. Represent the birds by circles with radius equal to their eat radius so the user can observe when a frog is gobbled up. Intro to Computer Science (MCS 260) predator-prey simulations L April / 43

Graphical User Interfaces

Graphical User Interfaces Graphical User Interfaces 1 User Interfaces GUIs in Python with Tkinter object oriented GUI programming 2 Mixing Colors specification of the GUI the widget Scale 3 Simulating a Bouncing Ball layout of

More information

Outline. making colors with scale widgets entering parameter values using the variables in Scale. sliding canvas coordinates animating a random walk

Outline. making colors with scale widgets entering parameter values using the variables in Scale. sliding canvas coordinates animating a random walk Outline 1 The Widget Scale making colors with scale widgets entering parameter values using the variables in Scale 2 Building an Animation sliding canvas coordinates animating a random walk 3 Summary +

More information

Outline. general information policies for the final exam

Outline. general information policies for the final exam Outline 1 final exam on Tuesday 5 May 2015, at 8AM, in BSB 337 general information policies for the final exam 2 some example questions strings, lists, dictionaries scope of variables in functions working

More information

User Interfaces. getting arguments of the command line a command line interface to store points fitting points with polyfit of numpy

User Interfaces. getting arguments of the command line a command line interface to store points fitting points with polyfit of numpy User Interfaces 1 Command Line Interfaces getting arguments of the command line a command line interface to store points fitting points with polyfit of numpy 2 Encapsulation by Object Oriented Programming

More information

Multithreaded Servers

Multithreaded Servers Multithreaded Servers 1 Serving Multiple Clients avoid to block clients with waiting using sockets and threads 2 Waiting for Data from 3 Clients running a simple multithreaded server code for client and

More information

Multithreading. processes and threads life cycle of a thread. the thread module the Thread class. two different algorithms run concurrently

Multithreading. processes and threads life cycle of a thread. the thread module the Thread class. two different algorithms run concurrently Multithreading 1 Concurrent Processes processes and threads life cycle of a thread 2 Multithreading in Python the thread module the Thread class 3 Producer/Consumer Relation two different algorithms run

More information

Graphical User Interfaces

Graphical User Interfaces to visualize Graphical User Interfaces 1 2 to visualize MCS 507 Lecture 12 Mathematical, Statistical and Scientific Software Jan Verschelde, 19 September 2011 Graphical User Interfaces to visualize 1 2

More information

User Interfaces. MCS 507 Lecture 11 Mathematical, Statistical and Scientific Software Jan Verschelde, 16 September Command Line Interfaces

User Interfaces. MCS 507 Lecture 11 Mathematical, Statistical and Scientific Software Jan Verschelde, 16 September Command Line Interfaces User 1 2 MCS 507 Lecture 11 Mathematical, Statistical and Scientific Software Jan Verschelde, 16 September 2011 User 1 2 command line interfaces Many programs run without dialogue with user, as $ executable

More information

defining the class Parabola extending the Parabola class for visualization

defining the class Parabola extending the Parabola class for visualization Class Hierarchies 1 Points and Lines points in the plane extending the classpoint representing lines in the plane visualizing lines 2 Parabolas defining the class Parabola extending the Parabola class

More information

making connections general transit feed specification stop names and stop times storing the connections in a dictionary

making connections general transit feed specification stop names and stop times storing the connections in a dictionary making connections 1 CTA Tables general transit feed specification stop names and stop times storing the connections in a dictionary 2 CTA Schedules finding connections between stops sparse matrices in

More information

PYTHON FOR KIDS A Pl ayfu l I ntrodu ctio n to Prog r am m i ng J a s o n R. B r i g g s

PYTHON FOR KIDS A Pl ayfu l I ntrodu ctio n to Prog r am m i ng J a s o n R. B r i g g s PYTHON FO R K I D S A P l ay f u l I n t r o d u c t i o n to P r o g r a m m i n g Jason R. Briggs Index Symbols and Numbers + (addition operator), 17 \ (backslash) to separate lines of code, 235 in strings,

More information

Threading the Code. Self-Review Questions. Self-review 11.1 What is a thread and what is a process? What is the difference between the two?

Threading the Code. Self-Review Questions. Self-review 11.1 What is a thread and what is a process? What is the difference between the two? Threading the Code 11 Self-Review Questions Self-review 11.1 What is a thread and what is a process? What is the difference between the two? Self-review 11.2 What does the scheduler in an operating system

More information

Outline. overview & concepts files and processes in UNIX the platform and os modules. importing the turtle module drawing a spiral colors with turtle

Outline. overview & concepts files and processes in UNIX the platform and os modules. importing the turtle module drawing a spiral colors with turtle Outline 1 Operating Systems overview & concepts files and processes in UNIX the platform and os modules 2 Turtle Graphics importing the turtle module drawing a spiral colors with turtle 3 Summary + Assignments

More information

Review for Second Midterm Exam

Review for Second Midterm Exam Review for Second Midterm Exam 1 Policies & Material 2 Questions modular design working with files object-oriented programming testing, exceptions, complexity GUI design and implementation MCS 260 Lecture

More information

Tkinter: Input and Output Bindings. Marquette University

Tkinter: Input and Output Bindings. Marquette University Tkinter: Input and Output Bindings Marquette University Tkinter Variables Tkinter contains a useful mechanism to connect widgets to variables This allows us to have variables change when widgets do and

More information

CMPSCI 119 Fall 2018 Wednesday, November 14, 2018 Midterm #2 Solution Key Professor William T. Verts

CMPSCI 119 Fall 2018 Wednesday, November 14, 2018 Midterm #2 Solution Key Professor William T. Verts CMPSCI 119 Fall 2018 Wednesday, November 14, 2018 Midterm #2 Solution Key Professor William T. Verts 25 Points What is the value of each expression below? Answer any 25; answer more for extra credit.

More information

Khan Academy JavaScript Study Guide

Khan Academy JavaScript Study Guide Khan Academy JavaScript Study Guide Contents 1. Canvas graphics commands with processing.js 2. Coloring 3. Variables data types, assignments, increments 4. Animation with draw loop 5. Math expressions

More information

Random Walks & Cellular Automata

Random Walks & Cellular Automata Random Walks & Cellular Automata 1 Particle Movements basic version of the simulation vectorized implementation 2 Cellular Automata pictures of matrices an animation of matrix plots the game of life of

More information

Advanced Web Programming

Advanced Web Programming Advanced Web Programming 1 Advanced Web Programming what we have covered so far 2 The SocketServer Module simplified development of network servers a server tells clients the time 3 A Forking Server instead

More information

# arrange Label in parent widget

# arrange Label in parent widget Much of today s software uses a point-and-click graphical user interface (GUI). The standard library modules Tkinter and Tix allow for portable, event-driven, GUI development in Python. A Python/Tkinter

More information

Assignment 6. INF109 Dataprogrammering for naturvitskap

Assignment 6. INF109 Dataprogrammering for naturvitskap Assignment 6 INF109 Dataprogrammering for naturvitskap This is the sixth of seven assignments. You can get a total of 15 points for this task. Deadline is Friday, 15 April, 23.59. Submit the report as

More information

Outline. the try-except statement the try-finally statement. exceptions are classes raising exceptions defining exceptions

Outline. the try-except statement the try-finally statement. exceptions are classes raising exceptions defining exceptions Outline 1 Exception Handling the try-except statement the try-finally statement 2 Python s Exception Hierarchy exceptions are classes raising exceptions defining exceptions 3 Anytime Algorithms estimating

More information

Investigation: Triangle congruencies.

Investigation: Triangle congruencies. Investigation: Triangle congruencies. In this investigation you will be discovering the properties of triangle congruencies. Specifically, if there are more than 4 ways to prove a triangle congruent. Step-By-Step

More information

callback, iterators, and generators

callback, iterators, and generators callback, iterators, and generators 1 Adding a Callback Function a function for Newton s method a function of the user to process results 2 A Newton Iterator defining a counter class refactoring the Newton

More information

Ecolab Agent based Predator-prey simulation in Matlab

Ecolab Agent based Predator-prey simulation in Matlab Ecolab Agent based Predator-prey simulation in Matlab 1 Description of model This Matlab based programme simulates a simple predator-prey system consisting of interacting populations of foxes and rabbits

More information

PYTHON MULTITHREADED PROGRAMMING

PYTHON MULTITHREADED PROGRAMMING PYTHON MULTITHREADED PROGRAMMING http://www.tutorialspoint.com/python/python_multithreading.htm Copyright tutorialspoint.com Running several threads is similar to running several different programs concurrently,

More information

ECS 10 Concepts of Computation Example Final Problems

ECS 10 Concepts of Computation Example Final Problems ECS 10 Concepts of Computation Example Final Problems 1. Here is a little program, not necessarily correct. ages= {} ages["cat"]=4 if 4 in ages: print ages[4] This program will... a) print cat b) print

More information

Random Walks & Cellular Automata

Random Walks & Cellular Automata Random Walks & Cellular Automata 1 Particle Movements basic version of the simulation vectorized implementation 2 Cellular Automata pictures of matrices an animation of matrix plots the game of life of

More information

S206E Lecture 13, 5/22/2016, Grasshopper Math and Logic Rules

S206E Lecture 13, 5/22/2016, Grasshopper Math and Logic Rules S206E057 -- Lecture 13, 5/22/2016, Grasshopper Math and Logic Rules Copyright 2016, Chiu-Shui Chan. All Rights Reserved. Interface of Math and Logic Functions 1. Basic mathematic operations: For example,

More information

Your (printed!) Name: CS 1803 Exam 2. Grading TA / Section: Monday, Oct 25th, 2010

Your (printed!) Name: CS 1803 Exam 2. Grading TA / Section: Monday, Oct 25th, 2010 Your (printed!) Name: CS 1803 Exam 2 Grading TA / Section: Monday, Oct 25th, 2010 INTEGRITY: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate

More information

Quick Reference Tables

Quick Reference Tables Quick Reference Tables Chapter 1 Raspberry Pi Startup Command Quick Reference Table Command startx sudo sudo shutdown -h now sudo shutdown -r now Launches the Raspbian desktop environment (GUI). Gives

More information

INHERITANCE AND INTERFACES 7

INHERITANCE AND INTERFACES 7 INHERITANCE AND INTERFACES 7 COMPUTER SCIENCE 61A October 16, 2014 1 Inheritance Today, we explore another powerful tool that comes with object-oriented programming inheritance. Suppose we want to write

More information

[CHAPTER] 1 INTRODUCTION 1

[CHAPTER] 1 INTRODUCTION 1 FM_TOC C7817 47493 1/28/11 9:29 AM Page iii Table of Contents [CHAPTER] 1 INTRODUCTION 1 1.1 Two Fundamental Ideas of Computer Science: Algorithms and Information Processing...2 1.1.1 Algorithms...2 1.1.2

More information

Running Cython and Vectorization

Running Cython and Vectorization Running Cython and Vectorization 1 Getting Started with Cython overview hello world with Cython 2 Numerical Integration experimental setup adding type declarations cdef functions & calling external functions

More information

Introduction to Recursion

Introduction to Recursion Recursive Patterns Introduction to Recursion CS Computer Programming Department of Computer Science Wellesley College Reminder: DCG What is Recursion? 8- Recursion is an instance of divide-conquer-glue

More information

This document should only be used with the Apple Macintosh version of Splosh.

This document should only be used with the Apple Macintosh version of Splosh. Splosh 1 Introduction Splosh is an easy to use art package that runs under both Microsoft Windows and the Macintosh Mac OS Classic or Mac OS X operating systems. It should however be noted that the Apple

More information

Easy Graphical User Interfaces

Easy Graphical User Interfaces Easy Graphical User Interfaces with breezypythongui Types of User Interfaces GUI (graphical user interface) TUI (terminal-based user interface) UI Inputs Outputs Computation Terminal-Based User Interface

More information

When to use the Grid Manager

When to use the Grid Manager 第 1 页共 5 页 2015/6/8 8:02 back next The Grid geometry manager puts the widgets in a 2-dimensional table. The master widget is split into a number of rows and columns, and each cell in the resulting table

More information

4. TROUBLESHOOTING PREVIOUS VERSIONS RUN LOLITRACK ALWAYS AS ADMIN WIBU SOFTWARE PROTECTION... 30

4. TROUBLESHOOTING PREVIOUS VERSIONS RUN LOLITRACK ALWAYS AS ADMIN WIBU SOFTWARE PROTECTION... 30 Version 4.2.0 CONTENTS 1. GETTING STARTED... 2 2. TYPICAL APPLICATIONS... 4 3. USER GUIDE... 5 3.1 SINGLE OBJECT MODE... 7 3.2 SINGLE ARENA MODE... 12 3.3 EVENT RECORDER... 19 3.4 BATCH TRACKING... 21

More information

CSCI 136 Written Exam #2 Fundamentals of Computer Science II Spring 2015

CSCI 136 Written Exam #2 Fundamentals of Computer Science II Spring 2015 CSCI 136 Written Exam #2 Fundamentals of Computer Science II Spring 2015 Name: This exam consists of 6 problems on the following 6 pages. You may use your double- sided hand- written 8 ½ x 11 note sheet

More information

The Pyth Language. Administrivia

The Pyth Language. Administrivia Administrivia The Pyth Language Lecture 5 Please make sure you have registered your team, created SSH keys as indicated on the admin page, and also have electronically registered with us as well. Prof.

More information

Grade 7/8 Math Circles November 3/4, M.C. Escher and Tessellations

Grade 7/8 Math Circles November 3/4, M.C. Escher and Tessellations Faculty of Mathematics Waterloo, Ontario N2L 3G1 Centre for Education in Mathematics and Computing Tiling the Plane Grade 7/8 Math Circles November 3/4, 2015 M.C. Escher and Tessellations Do the following

More information

Introduction to Programming Using Python Lecture 6. Dr. Zhang COSC 1437 Spring, 2018 March 01, 2018

Introduction to Programming Using Python Lecture 6. Dr. Zhang COSC 1437 Spring, 2018 March 01, 2018 Introduction to Programming Using Python Lecture 6 Dr. Zhang COSC 1437 Spring, 2018 March 01, 2018 Chapter 9 GUI Programming Using Tkinter Getting started with Tkinter with a simple example. Code example:

More information

CS 11 python track: lecture 4

CS 11 python track: lecture 4 CS 11 python track: lecture 4 Today: More odds and ends assertions "print >>" syntax more on argument lists functional programming tools list comprehensions More on exception handling More on object-oriented

More information

Data Structures III: K-D

Data Structures III: K-D Lab 6 Data Structures III: K-D Trees Lab Objective: Nearest neighbor search is an optimization problem that arises in applications such as computer vision, pattern recognition, internet marketing, and

More information

CS 112 Project Assignment: Visual Password

CS 112 Project Assignment: Visual Password CS 112 Project Assignment: Visual Password Instructor: Dan Fleck Overview In this project you will use Python to implement a visual password system. In the industry today there is ongoing research about

More information

CS 101 Computer Science I Fall Instructor Muller. stddraw API. (DRAFT of 1/15/2013)

CS 101 Computer Science I Fall Instructor Muller. stddraw API. (DRAFT of 1/15/2013) CS 101 Computer Science I Fall 2013 Instructor Muller stddraw API (DRAFT of 1/15/2013) This document describes the application programmer interface (API) for the stddraw library. An API describes the set

More information

Introduction Programming Using Python Lecture 8. Dr. Zhang COSC 1437 Fall 2017 Nov 30, 2017

Introduction Programming Using Python Lecture 8. Dr. Zhang COSC 1437 Fall 2017 Nov 30, 2017 Introduction Programming Using Python Lecture 8 Dr. Zhang COSC 1437 Fall 2017 Nov 30, 2017 Chapter 12 Inheritance and Class Design Review Suppose you will define classes to model circles, rectangles, and

More information

from Recursion to Iteration

from Recursion to Iteration from Recursion to Iteration 1 Quicksort Revisited using arrays partitioning arrays via scan and swap recursive quicksort on arrays 2 converting recursion into iteration an iterative version with a stack

More information

3.2 A Three-Bar Linkage 51

3.2 A Three-Bar Linkage 51 3.2 A Three-Bar Linkage 51 It may happen that the drawing in Euclidean view is too big or too small. You can use the zooming tools to change this. There is a Zoom-In and a Zoom-Out tool below the Euclidean

More information

Lecture 24. GUI Applications

Lecture 24. GUI Applications Lecture 24 GUI Applications Announcements for This Lecture Prelim 2 Difficulty was reasonable Mean: 71, Median: 74 Just 2 points below target What do grades mean? A: 80s+ (maybe 78+) B: 60s+ C: 30+ Final

More information

UNIT 10A Visualizing Data: Graphics in Python. Drawing using Python. We will be using Python's interface to Tcl/Tk, a cross-plaoorm graphics library.

UNIT 10A Visualizing Data: Graphics in Python. Drawing using Python. We will be using Python's interface to Tcl/Tk, a cross-plaoorm graphics library. UNIT 10A Visualizing Data: Graphics in Python 1 Drawing using Python We will be using Python's interface to Tcl/Tk, a cross-plaoorm graphics library. To use this, you should be logged in directly into

More information

Lecture 24. GUI Applications

Lecture 24. GUI Applications Lecture 24 GUI Applications Announcements for This Lecture Assignments A6 due midnight TONIGHT Last day for consultants Also, fill out survey A7 due December 11 Instructions posted today Focus of today

More information

List Comprehensions and Simulations

List Comprehensions and Simulations List Comprehensions and Simulations 1 List Comprehensions examples in the Python shell zipping, filtering, and reducing 2 Monte Carlo Simulations testing the normal distribution the Mean Time Between Failures

More information

ENGR/CS 101 CS Session Lecture 15

ENGR/CS 101 CS Session Lecture 15 ENGR/CS 101 CS Session Lecture 15 Log into Windows/ACENET (reboot if in Linux) Use web browser to go to session webpage http://csserver.evansville.edu/~hwang/f14-courses/cs101.html Right-click on lecture15.py

More information

Python Language Basics II. Georgia Advanced Computing Resource Center University of Georgia Zhuofei Hou, HPC Trainer

Python Language Basics II. Georgia Advanced Computing Resource Center University of Georgia Zhuofei Hou, HPC Trainer Python Language Basics II Georgia Advanced Computing Resource Center University of Georgia Zhuofei Hou, HPC Trainer zhuofei@uga.edu 1 Outline What is GACRC? Program Structure: Control Flow and Loop Function:

More information

Midterm Exam II MCS 275 Programming Tools 14 March 2017

Midterm Exam II MCS 275 Programming Tools 14 March 2017 NAME: answers The exam is closed book, no notes and no computer. All your answers to the questions below must be submitted on paper. Write your name on this sheet and submit it with your answers. Please

More information

CSc 110, Spring 2017 Lecture 37: Critters. Adapted from slides by Marty Stepp and Stuart Reges

CSc 110, Spring 2017 Lecture 37: Critters. Adapted from slides by Marty Stepp and Stuart Reges CSc 110, Spring 2017 Lecture 37: Critters Adapted from slides by Marty Stepp and Stuart Reges 1 Calling overridden methods Subclasses can call overridden methods with super super(classname, self).method(parameters)

More information

Lab 2: Booleans, Strings, Random Numbers, Recursion, Variables, Input function

Lab 2: Booleans, Strings, Random Numbers, Recursion, Variables, Input function Lab 2: Booleans, Strings, Random Numbers, Recursion, Variables, Input function Due: Mar25 (Note that this is a 2-week lab) This lab must be done using paired partners. You should choose a different partner

More information

Running Cython and Vectorization

Running Cython and Vectorization Running Cython and Vectorization 1 Getting Started with Cython overview hello world with Cython 2 Numerical Integration experimental setup adding type declarations cdef functions & calling external functions

More information

Programming Training. This Week: Tkinter for GUI Interfaces. Some examples

Programming Training. This Week: Tkinter for GUI Interfaces. Some examples Programming Training This Week: Tkinter for GUI Interfaces Some examples Tkinter Overview Set of widgets designed by John K. Ousterhout, 1987 Tkinter == Tool Kit Interface Mean to be driven by Tcl (Toolkit

More information

Noughts and Crosses. Step 1: Drawing the grid. Introduction

Noughts and Crosses. Step 1: Drawing the grid. Introduction 6 Noughts and Crosses These projects are for use inside the UK only. All Code Clubs must be registered. You can check registered clubs at www.codeclub.org.uk/. This coursework is developed in the open

More information

CS 112: Intro to Comp Prog

CS 112: Intro to Comp Prog CS 112: Intro to Comp Prog Tkinter Layout Managers: place, pack, grid Custom Frames Widgets In-depth StringVar tkfont Upcoming Tk To use Tkinter Widgets (components: buttons, labels, etc). You must import

More information

CMPSCI 119 Spring 2014 Friday, November 7, 2014 Midterm #2 Solution Key Professor William T. Verts

CMPSCI 119 Spring 2014 Friday, November 7, 2014 Midterm #2 Solution Key Professor William T. Verts CMPSCI 119 Spring 2014 Friday, November 7, 2014 Midterm #2 Solution Key Professor William T. Verts 20 Points Rewrite the following code to use for-loops instead of while-loops. Use as few Python statements

More information

CPSC 217 Assignment 4

CPSC 217 Assignment 4 CPSC 217 Assignment 4 Due: Friday December 8, 2017 at 11:55pm Weight: 7% Sample Solution Length: Approximately 130 lines (No comments and no code for the A+ part) Individual Work: All assignments in this

More information

Working with Transformations on the Coordinate Plane

Working with Transformations on the Coordinate Plane Working with Transformations on the Coordinate Plane Movies create the illusion of movement by showing us 24 images per second. When the human eye processes 24 images per second it is interpreted in our

More information

CSC 110 Final Exam. ID checked

CSC 110 Final Exam. ID checked ID checked CSC 110 Final Exam Name: Date: 1. Write a Python program that asks the user for a positive integer n and prints out n evenly spaced values between 0 and 10. The values should be printed with

More information

UNIVERSITY OF TORONTO Faculty of Arts and Science DECEMBER 2015 EXAMINATIONS. CSC309H1 F Programming on the Web Instructor: Ahmed Shah Mashiyat

UNIVERSITY OF TORONTO Faculty of Arts and Science DECEMBER 2015 EXAMINATIONS. CSC309H1 F Programming on the Web Instructor: Ahmed Shah Mashiyat UNIVERSITY OF TORONTO Faculty of Arts and Science DECEMBER 2015 EXAMINATIONS CSC309H1 F Programming on the Web Instructor: Ahmed Shah Mashiyat Duration - 2 hours No Aid Allowed, Pass Mark: 14 out of 35

More information

Using Inheritance to Share Implementations

Using Inheritance to Share Implementations Using Inheritance to Share Implementations CS 5010 Program Design Paradigms "Bootcamp" Lesson 11.2 Mitchell Wand, 2012-2015 This work is licensed under a Creative Commons Attribution-NonCommercial 4.0

More information

Search. The Nearest Neighbor Problem

Search. The Nearest Neighbor Problem 3 Nearest Neighbor Search Lab Objective: The nearest neighbor problem is an optimization problem that arises in applications such as computer vision, pattern recognition, internet marketing, and data compression.

More information

CSc 110, Spring 2017 Lecture 38: Critters. Adapted from slides by Marty Stepp and Stuart Reges

CSc 110, Spring 2017 Lecture 38: Critters. Adapted from slides by Marty Stepp and Stuart Reges CSc 110, Spring 2017 Lecture 38: Critters Adapted from slides by Marty Stepp and Stuart Reges 1 Calling overridden methods Subclasses can call overridden methods with super super(classname, self).method(parameters)

More information

Graphics Module Reference

Graphics Module Reference Graphics Module Reference John M. Zelle Version 3.2, Spring 2005 1 Overview The package graphics.py is a simple object oriented graphics library designed to make it very easy for novice programmers to

More information

FIREWORKS TRICKS AND TIPS CS6

FIREWORKS TRICKS AND TIPS CS6 FIREWORKS TRICKS AND TIPS CS6 Here are some cool things you can do with Fireworks to create wonderful works of art! SHAPES AND EFFECTS Draw a shape with the shape tool. Fill with color. Change the line

More information

processing data from the web

processing data from the web processing data from the web 1 CTA Tables general transit feed specification stop identification and name finding trips for a given stop 2 CTA Tables in MySQL files in GTFS feed are tables in database

More information

CS 112: Intro to Comp Prog

CS 112: Intro to Comp Prog CS 112: Intro to Comp Prog Importing modules Branching Loops Program Planning Arithmetic Program Lab Assignment #2 Upcoming Assignment #1 Solution CODE: # lab1.py # Student Name: John Noname # Assignment:

More information

Generations Monograms + Monogramming Masterpieces By Bernadette Griffith Generations Software

Generations Monograms + Monogramming Masterpieces By Bernadette Griffith Generations Software Creating monograms in Generations Monograms+ is a snap. Just select one of the build in monogram templates, a True Type Font lettering style and one of the decorative borders and frames included in the

More information

Assignment 4: Due Friday Mar 11 at 6pm

Assignment 4: Due Friday Mar 11 at 6pm CS1110 Spring 2016 Assignment 4: Due Friday Mar 11 at 6pm You must work either on your own or with one partner. If you work with a partner, you and your partner must first register as a group in CMS (this

More information

lambda forms map(), reduce(), filter(), eval(), and apply() estimating π with list comprehensions

lambda forms map(), reduce(), filter(), eval(), and apply() estimating π with list comprehensions Outline 1 Guessing Secrets functions returning functions oracles and trapdoor functions 2 anonymous functions lambda forms map(), reduce(), filter(), eval(), and apply() estimating π with list comprehensions

More information

Lecture 4. while and for loops if else test Tuples Functions. Let us start Python Ssh (putty) to UNIX/Linux computer puccini.che.pitt.

Lecture 4. while and for loops if else test Tuples Functions. Let us start Python Ssh (putty) to UNIX/Linux computer puccini.che.pitt. Lecture 4 while and for loops if else test Tuples Functions Let us start Python Ssh (putty) to UNIX/Linux computer puccini.che.pitt.edu Launching Python > python Quick Reminder: while Loop Example >>>

More information

Lecture 27. Lecture 27: Regular Expressions and Python Identifiers

Lecture 27. Lecture 27: Regular Expressions and Python Identifiers Lecture 27 Lecture 27: Regular Expressions and Python Identifiers Python Syntax Python syntax makes very few restrictions on the ways that we can name our variables, functions, and classes. Variables names

More information

Critters. Critter #2 Attack.ROAR Attack.POUNCE Attack.SCRATCH. Critter #1

Critters. Critter #2 Attack.ROAR Attack.POUNCE Attack.SCRATCH. Critter #1 Critters This assignment was co-created by Stuart Reges and Marty Stepp. This program focuses on classes, objects, and inheritance. You will write the following files: Ant.java, Bird.java, Crab.java, FireAnt.java,

More information

Chapter 9 GUI Programming Using Tkinter. Copyright 2012 by Pearson Education, Inc. All Rights Reserved.

Chapter 9 GUI Programming Using Tkinter. Copyright 2012 by Pearson Education, Inc. All Rights Reserved. Chapter 9 GUI Programming Using Tkinter 1 Motivations Tkinter is not only a useful tool for developing GUI projects, but also a valuable pedagogical tool for learning object-oriented programming. 2 Objectives

More information

Programming Languages

Programming Languages Programming Languages Week 9 Exercises Object-oriented programming in Python (2) Objects are especially useful for factoring state and behaviour. When two (or more) different classes of object are specicialisations

More information

Object Oriented Programming

Object 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 information

Outline. measuring complexity: big-oh complexity classes counting flops: floating-point operations

Outline. measuring complexity: big-oh complexity classes counting flops: floating-point operations Outline 1 Complexity and Cost measuring complexity: big-oh complexity classes counting flops: floating-point operations 2 Cost of Algorithms timing Python programs the unix command time try-except costs

More information

COMP519 Web Programming Lecture 21: Python (Part 5) Handouts

COMP519 Web Programming Lecture 21: Python (Part 5) Handouts COMP519 Web Programming Lecture 21: Python (Part 5) Handouts Ullrich Hustadt Department of Computer Science School of Electrical Engineering, Electronics, and Computer Science University of Liverpool Functions

More information

Lab 2: Booleans, Strings, Random Numbers, Recursion, Variables, Input function

Lab 2: Booleans, Strings, Random Numbers, Recursion, Variables, Input function Lab 2: Booleans, Strings, Random Numbers, Recursion, Variables, Input function Due: Mar13 (Note that this is a 2-week lab) This lab must be done using paired partners. You should choose a different partner

More information

Introduction to VPython for E&M This tutorial will guide you through the basics of programming in VPython

Introduction to VPython for E&M This tutorial will guide you through the basics of programming in VPython Introduction to VPython for E&M This tutorial will guide you through the basics of programming in VPython VPython is a programming language that allows you to easily make 3-D graphics and animations. We

More information

Midterm #1 Fall minutes

Midterm #1 Fall minutes 15-112 Midterm #1 Fall 2014 80 minutes Name: Andrew ID: @andrew.cmu.edu Section: INSTRUCTIONS You may not use any books, notes, or electronic devices during this exam. You may not ask questions about the

More information

Outline. tallying the votes global and local variables call by value or call by reference. of variable length using keywords for optional arguments

Outline. tallying the votes global and local variables call by value or call by reference. of variable length using keywords for optional arguments Outline 1 Histograms tallying the votes global and local variables call by value or call by reference 2 Arguments of Functions of variable length using keywords for optional arguments 3 Functions using

More information

Lesson 18: Animation. Computer Programming is Fun!

Lesson 18: Animation. Computer Programming is Fun! Lesson 18: Animation So how do you make your drawings move and change? That's what this section is about. I'd like to introduce you to your new friend, Mr. Timer. A timer gives you the ability to tell

More information

This text is used together with Mark Pilgrims book Dive Into Python 3 for the Arthead course Python Fundamentals.

This text is used together with Mark Pilgrims book Dive Into Python 3 for the Arthead course Python Fundamentals. 2 About this text This text is used together with Mark Pilgrims book Dive Into Python 3 for the Arthead course Python Fundamentals. The first part is written for Python 2 and at the end there is a section

More information

mith College Computer Science Week 7 CSC111 Fall 2015 Dominique Thiébaut

mith 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 information

Graphics Module Reference

Graphics Module Reference Graphics Module Reference John M. Zelle Version 3.0, Winter 2005 1 Overview The package graphics.py is a simple object oriented graphics library designed to make it very easy for novice programmers to

More information

CLASS : I - COMPUTER SCIENCE TERM- I

CLASS : I - COMPUTER SCIENCE TERM- I CLASS : I - COMPUTER SCIENCE TERM- I LESSON 1 USES OF COMPUTERS I. New Words 1. Library 2. Bank 3. Railway 4. Station 5. Computers 6. Mixie 7. Work 8. Fan 9. Machine II. Say YES or NO to the statement

More information

CMPSCI 119 Fall 2018 Thursday, November 29, 2018 Midterm #3 Solution Key Professor William T. Verts

CMPSCI 119 Fall 2018 Thursday, November 29, 2018 Midterm #3 Solution Key Professor William T. Verts CMPSCI 119 Fall 2018 Thursday, November 29, 2018 Midterm #3 Solution Key Professor William T. Verts 25 Points What is the value of each expression below? Answer any 25; answer more for extra credit.

More information

Structure and Interpretation of Computer Programs

Structure and Interpretation of Computer Programs CS 61A Fall 2012 Structure and Interpretation of Computer Programs Alternate Midterm 2 Solutions INSTRUCTIONS You have 2 hours to complete the exam. The exam is closed book, closed notes, closed computer,

More information

mith College Computer Science Lecture Notes CSC111 Week 7 Spring 2018 Dominique Thiébaut

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 information

Python review. 1 Python basics. References. CS 234 Naomi Nishimura

Python 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 information

IT101. Graphical User Interface

IT101. Graphical User Interface IT101 Graphical User Interface Foundation Swing is a platform-independent set of Java classes used for user Graphical User Interface (GUI) programming. Abstract Window Toolkit (AWT) is an older Java GUI

More information