Difference between revisions of "CSC111 Class Page 2014"
(→Second Half) |
|||
(99 intermediate revisions by the same user not shown) | |||
Line 28: | Line 28: | ||
=Weekly Schedule= | =Weekly Schedule= | ||
<br /> | <br /> | ||
− | ==First Half== | + | ==First Half (Feb-Spring Break)== |
<br /> | <br /> | ||
− | <!-- | + | <!-- {| class="mw-collapsible mw-collapsed" style="width:100%" border="1" --> |
− | {| class="mw-collapsible | + | {| class="mw-collapsible" style="width:100%" border="1" |
|- style="background:#ffdead;" | |- style="background:#ffdead;" | ||
|'''Week''' || '''Topics''' || '''Reading''' | |'''Week''' || '''Topics''' || '''Reading''' | ||
Line 422: | Line 422: | ||
==Spring Break == | ==Spring Break == | ||
<br /> | <br /> | ||
− | <center>[[File:animatedBeach.gif]]</center> | + | <!--center>[[File:animatedBeach.gif]]</center--> |
<br /> | <br /> | ||
− | ==Second Half== | + | ==Second Half (Spring Break-May)== |
<br /> | <br /> | ||
Line 464: | Line 464: | ||
---- | ---- | ||
* [[CSC111 Lab 8 2014 | Lab #8]] and [[CSC111 Lab 8 Solution Program 2014| solution programs]] | * [[CSC111 Lab 8 2014 | Lab #8]] and [[CSC111 Lab 8 Solution Program 2014| solution programs]] | ||
− | * [[CSC111 Homework 8 2014 | Homework #8]] | + | * [[CSC111 Homework 8 2014 | Homework #8]] and [[CSC111 Homework 8 Solution Programs 2014| solution programs]] |
|| | || | ||
* Reading | * Reading | ||
Line 578: | Line 578: | ||
print() | print() | ||
</source> | </source> | ||
− | ** Catching errors in Python | + | ** Catching errors in Python: ''exceptions'' |
*** [https://docs.python.org/3.3/tutorial/errors.html The Python documentation] | *** [https://docs.python.org/3.3/tutorial/errors.html The Python documentation] | ||
*** [[CSC111 Exercises with Exceptions: try/except| Exercises]] | *** [[CSC111 Exercises with Exceptions: try/except| Exercises]] | ||
− | + | ||
+ | ** (early end of class: Presentation of the Major) | ||
<br /> | <br /> | ||
---- | ---- | ||
− | * [[CSC111_Lab_9_2014 | Lab #9]] | + | * [[CSC111_Lab_9_2014 | Lab #9]] and [[CSC111 Lab 9 Solution Programs 2014| solution programs]] |
− | * [[CSC111_Homework_9_2014 | Homework #9]] | + | * [[CSC111_Homework_9_2014 | Homework #9]] and [[CSC111 Homework 9 Solution Programs 2014 | solution programs]] |
|| | || | ||
* Reading | * Reading | ||
Line 596: | Line 597: | ||
| Week 11 <br /> 4/7<br /> | | Week 11 <br /> 4/7<br /> | ||
|| | || | ||
+ | * <font color="red">'''Saturday/Sunday'''</font>: Moodle Quiz on Chapter 7 on '''Files and Exceptions'''. The quiz will close right before Monday's class. | ||
* '''Monday''' | * '''Monday''' | ||
+ | ** Catching Errors, Continued | ||
+ | *** [[CSC111 Exercises with Exceptions: try/except| Exercises]] | ||
+ | *** Advantages | ||
+ | **** Cleaner code, easier to write | ||
+ | **** Clear separation of "regular code" and "code handling problems" (see [http://docs.oracle.com/javase/tutorial/essential/exceptions/advantages.html this reference] for an example) | ||
+ | **** Almost same speed as original code when using try/except | ||
+ | ** <font color="magenta">Introduction to Object Oriented Programming</font> (OOP) | ||
+ | *** The concept: a black box with buttons on the front, and a blueprint to help build it. | ||
+ | *** Example 1: [[CSC111_Simple_Programs_Introducing_OOP#Program_1:_NO_OOP|A simple program keeping track of a collection of records]]. Does not use OOP | ||
+ | *** Example 2: [[CSC111_Simple_Programs_Introducing_OOP#Same_Program.2C_using_OOP|The same program, using OOP]]. | ||
+ | <br /> | ||
* '''Wednesday''' | * '''Wednesday''' | ||
+ | ** Something to learn by heart: '''LIST.append() does not return anything,''', but '''STRING.replace() does''' | ||
+ | ** Something to remember: '''If a function returns something of a given type, it must always return something of this type. The exception is that it can return ''None'' which does not have a type''' | ||
+ | ** Back to [[CSC111_Simple_Programs_Introducing_OOP#Same_Program.2C_using_OOP|Example 2 from Monday's class]] | ||
+ | ** Rules and definitions | ||
+ | *** The ''interface'' | ||
+ | *** the ''DOT notation''. | ||
+ | *** ''Private'' versus ''public'' member variables | ||
+ | *** ''Private'' versus ''public'' methods | ||
+ | *** What if a method needs to call another method of the same class? | ||
+ | ** Example 3: Creating a '''Dog''' class (use the '''Person''' class as example), with two '''member variables''': | ||
+ | *** a '''tag name''' (string) | ||
+ | *** a '''vaccinated''' status (boolean) | ||
+ | <br /> | ||
* '''Friday''' (''Visit by admitted students'') | * '''Friday''' (''Visit by admitted students'') | ||
+ | ** Reminder: Quiz during the weekend on Python objects and classes | ||
+ | ** int to month name: an easy solution | ||
+ | :::<source lang="python"> | ||
+ | def nameOfMonth( num ): | ||
+ | months = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", | ||
+ | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] | ||
+ | return months[ num ] | ||
+ | </source> | ||
+ | ** is "Hello" in the user input? | ||
+ | :::<source lang="python"> | ||
+ | ans = input( "> " ) | ||
+ | if ans.lower().find( "hello" ) == -1: | ||
+ | bePolite( ) | ||
+ | </source> | ||
+ | <br /> | ||
+ | ** Tips & Tricks for programming (life) | ||
+ | *** print | ||
+ | *** start small | ||
+ | ** Creating a new class: '''People''', a list of '''Person''' objects. We build on the [[CSC111_Simple_Programs_Introducing_OOP | previous example seen in class]]. | ||
+ | ** Overview of [[CSC111 Homework 10 2014 | Homework #10]] | ||
<br /> | <br /> | ||
− | |||
---- | ---- | ||
− | * | + | * [[CSC111 Lab 10 2014 | Lab #10]] and [[CSC111 Lab 10 Solution Programs 2014| solution programs]] |
+ | * [[CSC111 Homework 10 2014 | Homework #10]] and [[CSC11 Homework 10 Solution Programs 2014| solution programs]] | ||
+ | * [[CSC111_Homework_13_2014| Make-up Homework]] and [[CSC111_Homework 13 Solution Program 2014| solution program]] | ||
|| | || | ||
* Reading | * Reading | ||
− | * | + | * We will skip Chapter 8 and move on to Chapter 9 this week. |
+ | * Read Chapter 9! | ||
<!-- ================================================================== --> | <!-- ================================================================== --> | ||
|- style="background:#eeeeff" valign="top" | |- style="background:#eeeeff" valign="top" | ||
| Week 12 <br /> 4/14<br /> | | Week 12 <br /> 4/14<br /> | ||
|| | || | ||
+ | * <font color="red">'''Saturday/Sunday'''</font>: Moodle Quiz on '''Classes and Objects'''. The quiz will close right before Monday's class. | ||
* '''Monday''' | * '''Monday''' | ||
+ | ** [[CSC111 Exercises on Classes and Objects | Exercises on objects and classes]] | ||
+ | <br /> | ||
* '''Wednesday''' | * '''Wednesday''' | ||
+ | <br /> | ||
+ | ** Graphics (Covered in Chapter 2) | ||
+ | *** The ''window'' | ||
+ | *** The ''canvas'' | ||
+ | *** Horstmann's [[CSC111 Horstmann's Graphics Library | graphic library]] | ||
+ | *** '''Skeleton program''' | ||
+ | :::<source lang="python"> | ||
+ | from graphics import GraphicsWindow | ||
+ | |||
+ | MAXWIDTH = 800 | ||
+ | MAXHEIGHT = 600 | ||
+ | |||
+ | def main(): | ||
+ | win = GraphicsWindow(MAXWIDTH, MAXHEIGHT) | ||
+ | canvas = win.canvas() | ||
+ | |||
+ | #--- add new code here --- | ||
+ | |||
+ | |||
+ | win.wait() | ||
+ | win.close() | ||
+ | |||
+ | main() | ||
+ | </source> | ||
+ | *** Setting the color inside shapes | ||
+ | :::<source lang="python"> | ||
+ | canvas.setFill( red, green, blue ) | ||
+ | </source> | ||
+ | *** Drawing rectangles: | ||
+ | :::<source lang="python"> | ||
+ | canvas.drawRect( x, y, width, height ) | ||
+ | </source> | ||
+ | *** Drawing circles | ||
+ | :::<source lang="python"> | ||
+ | canvas.drawOval( x, y, width, height ) | ||
+ | </source> | ||
+ | |||
+ | <center>[[Image:CarForGraphics.jpg|400px]]</center> | ||
* '''Friday''' | * '''Friday''' | ||
+ | ** Review of [[CSC111_Lab_11_2014 | Lab #11]] | ||
+ | ** A class with a top and a car without one: a case of '''Class Inheritance''' | ||
+ | ** [[CSC111 Car With Top and Without Hard Top | Building up to an inherited class]] | ||
+ | ** [[CSC111 Exercise with Class Inheritance | Exercise]] | ||
<br /> | <br /> | ||
---- | ---- | ||
− | * | + | * [[CSC111_Lab_11_2014 | Lab #11]] and [[CSC111 Lab 11 Solution Program 2014| solution program]] |
+ | * [[CSC111 Homework 11 2014| Homework #11]] and [[CSC111 Homework 11 Solution Program 2014| Solution program]] | ||
|| | || | ||
* Reading | * Reading | ||
− | * | + | * We continue working with objects and classes this week, so the material covered in Chapter 9 is definitely still a good reference to visit and visit again. |
+ | * We will use objects in the context of graphics this week, so the material you already read in Chapter 2 will be a good reference for us. | ||
+ | * One of the appendices in the book has a good coverage of the graphics library (starting Page A-24) and all the methods available. | ||
+ | * Class inheritance is covered in Chapter 10 of the book. Read the first 4 sections (stop at Section 10.5, excluded). | ||
<!-- ================================================================== --> | <!-- ================================================================== --> | ||
|- style="background:#ffffff" valign="top" | |- style="background:#ffffff" valign="top" | ||
| Week 13 <br /> 4/21<br /> | | Week 13 <br /> 4/21<br /> | ||
|| | || | ||
+ | * <font color="red">'''Saturday/Sunday'''</font>: Moodle Quiz on '''Classes and Inheritance'''. The quiz will close right before Monday's class. | ||
+ | <br /> | ||
* '''Monday''' | * '''Monday''' | ||
− | * '''Wednesday''' | + | ** Adding motion to graphic objects. [[CSC111 Moving Graphic Objects | Example]] |
+ | ** Resizing a graphic object. [[CSC111 Resizing Graphic Objects | Example]] | ||
+ | ** [[Image:CallBackSetupForGraphics.png|right|200px]] A new concept: ''Event-Driven Programming'' | ||
+ | ** Adding event-driven capability to out graphics library: [[CSC111 graphics111.py 2014| graphics111.py]] | ||
+ | *** Circle, Wheel, Rectangle and Polygon classes | ||
+ | *** Menu class | ||
+ | *** Example Programs | ||
+ | <br /> | ||
+ | [[Image:HeleneVisentin.jpg|right|150px]] | ||
+ | * '''Wednesday''': | ||
+ | ** '''Guest Lecture:''' Prof. Helene Visentin, on mapping Paris throughout the ages. | ||
+ | *** [http://albus.smith.edu/paris/ http://albus.smith.edu/paris/] | ||
+ | ** What is the field of Digital Humanities? | ||
+ | *** [http://cs.smith.edu/dftwiki/images/DigitalHumanities.key Keynote presentation] ([http://cs.smith.edu/dftwiki/images/DigitalHumanities.pdf pdf]) | ||
+ | ** Class discussion: Mapping the campus | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
* '''Friday''' | * '''Friday''' | ||
+ | ** Animated Objects | ||
+ | <br /> | ||
+ | <center><videoflash>4GxPrESfdnM</videoflash></center> | ||
+ | <br /> | ||
+ | ** [[CSC111 Exercises with Global Variables| Playing with global variables]] | ||
+ | ** [[CSC1111 Lab 12 Solution Programs | A review of Lab #12]] | ||
+ | ** An introduction to sets | ||
+ | *** Console demo | ||
+ | ::::<source lang="python"> | ||
+ | a = { 'dog', 'cat' } | ||
+ | b = set( [] ) | ||
+ | a.add( 'dog' ) | ||
+ | a.discard( 'cat' ) | ||
+ | len( a ) | ||
+ | sorted( a ) | ||
+ | a.intersection( b ) | ||
+ | a.union( b ) | ||
+ | L1 = [ 1, 2, 3, 3, 3, 3, 3, 4, 5 ] | ||
+ | d = set( L1 ) | ||
+ | # Exercise: take a list and remove all its duplicates | ||
+ | # Exercise: count unique words in a string, with lists, with sets | ||
+ | </source> | ||
+ | *** [[CSC111 Counting Unique Words | Example]] | ||
+ | |||
+ | <!--center><videoflash>X347nTSkNNQ</videoflash></center--> | ||
+ | <br /> | ||
<br /> | <br /> | ||
---- | ---- | ||
− | * | + | * [[CSC111_Lab_12_2014| Lab #12]] and [[CSC1111 Lab 12 Solution Programs | solution programs]] |
+ | * [[CSC111_Homework_12_2014 | Homework #12]] | ||
|| | || | ||
* Reading | * Reading | ||
− | * | + | ** [http://en.wikipedia.org/wiki/Event-driven_programming Wikipedia has a short article] introducing event-driven programming. |
+ | ** Sets and Dictionaries are covered in Chapter 8. Read Sections 1 and 2, and stop at 8.3. | ||
+ | |||
<!-- ================================================================== --> | <!-- ================================================================== --> | ||
<!-- ================================================================== --> | <!-- ================================================================== --> | ||
Line 640: | Line 788: | ||
|| | || | ||
* '''Monday''' | * '''Monday''' | ||
+ | ** Back to the [[CSC111 Counting Unique Words | example]] on sets. Making the counting of unique words even faster! | ||
+ | ** Dictionaries. Dictionaries, like sets, are '''data structures''': data organized in a specific way so as to make some problems easier to write, or faster to execute, or more memory efficient. | ||
+ | ** Playing with dictionaries in the console: | ||
+ | >>> dict = {} | ||
+ | >>> dict = { "apple":1, "pear":3, "banana":6 } | ||
+ | >>> dict | ||
+ | >>> dict[ "pear" ] | ||
+ | >>> dict[ "orange" ] | ||
+ | >>> dict[ "kiwi" ] = 12 | ||
+ | >>> dict.keys() | ||
+ | >>> dict.values() | ||
+ | >>> dict.items() | ||
+ | >>> for key in dict: | ||
+ | print( key ) | ||
+ | >>> for key in dict: | ||
+ | print( key, dict[key] ) | ||
+ | >>> contacts = {} | ||
+ | >>> contacts[ "Marie" ] = "111 22 33" | ||
+ | >>> contacts[ "Alex" ] = "222 33 44" | ||
+ | >>> contacts[ "Francis" ] = "333 44 55" | ||
+ | >>> contacts.pop( "Alex" ) | ||
+ | [[Image:MagicHat.png|150px|right]] | ||
+ | ** Find the frequency of occurrence of words in a sentence | ||
+ | ** Find the 10 most frequent words in James Joyce's Ulysses | ||
+ | ** '''Recursion''' | ||
+ | *** A simple first example: factorials: the mathematical expression, and its version in Python. | ||
+ | *** Wrapping text recursively[[CSC111 Recursive Text-Wrapping|.]] | ||
+ | *** The towers of hanoi | ||
+ | <br /> | ||
* '''Wednesday''' | * '''Wednesday''' | ||
− | * '''Friday''': <font color="magenta">Final Take-Home EXAM</font> | + | ** Continue with Factorial Program |
+ | ** [[CSC111_RecursiveFactorial.py| Python code]] | ||
+ | ** Animation [[Media:FactorialCSC111Animation.key.zip | Zipped Keynote]] | ||
+ | <br /> | ||
+ | <center>[[File:AnimatedTowersOfHanoi.gif]]</center> | ||
+ | <br /> | ||
+ | ** Towers of Hanoi, the [https://www.youtube.com/watch?v=Kt3L5nip-FQ movie] | ||
+ | ** [[CSC231_Analysis_of_the_Towers_of_Hanoi|How long would it take for 64 disks?]] | ||
+ | ** [[CSC111_BinarySearch.py | Binary search]] | ||
+ | ** [[CSC111 FractalTree.py | Fractal tree]] | ||
+ | <br /> | ||
+ | * '''Friday''': | ||
+ | ** A couple more words about recursion... | ||
+ | ** [[CSC111 visitMaze.py | maze-visiting program]] | ||
+ | **<font color="magenta">[[CSC111_Final_Exam_2014 |Final Take-Home EXAM]]</font> | ||
+ | <br /> | ||
<br /> | <br /> | ||
− | |||
---- | ---- | ||
− | * | + | * [[CSC111_Lab_13_2014| Lab #13]] and [[CSC111 Lab 13 Solution Program 2014|solution program]] |
|| | || | ||
* Reading | * Reading | ||
− | * | + | ** Dictionaries and sets are covered in Chapter 8. Section 8.3 is especially interesting. |
− | + | ** Recursion is covered in Chapter 11. Read up to, but not including, Section 5. | |
|} | |} | ||
Line 656: | Line 847: | ||
=Links and Resources= | =Links and Resources= | ||
<br /> | <br /> | ||
+ | ==Map of Smith College== | ||
+ | ===Full Map=== | ||
+ | <br /> | ||
+ | <center> [[Image:SmithMap2.jpg|500px]]</center> | ||
+ | <br /> | ||
+ | ===Reduced Map=== | ||
+ | <br /> | ||
+ | <center>[[Image:SmithMapSmall.gif|500px]]</center> | ||
+ | <br /> | ||
+ | ===Dates of Construction for Smith Buildings=== | ||
+ | <br /> | ||
+ | * The dates for the construction of different buildings on campus are available [[Smith College Building Construction Dates| here]] | ||
+ | <br /> | ||
+ | ===A Skeleton Python Program for Displaying An Image=== | ||
+ | <br /> | ||
+ | <source lang="python"> | ||
+ | # Skeleton program for displaying a gif image. | ||
+ | # D. Thiebaut | ||
+ | # Warning: will not work with a jpg or png image! If you | ||
+ | # need to convert your image to gif, use a Web service. | ||
+ | # | ||
+ | |||
+ | from graphics111 import * | ||
+ | import tkinter as tk | ||
+ | |||
+ | MAXWIDTH = 800 | ||
+ | MAXHEIGHT = 600 | ||
+ | |||
+ | |||
+ | # ======================================================== | ||
+ | # Main Program | ||
+ | # ======================================================== | ||
+ | def main(): | ||
+ | gifFileName = "SmithMapSmall.gif" | ||
+ | # open the window and get access to its canvas | ||
+ | win = GraphicsWindow(MAXWIDTH, MAXHEIGHT) | ||
+ | canvas = win.canvas() | ||
+ | |||
+ | # put gif image on canvas | ||
+ | photo = tk.PhotoImage( file=gifFileName ) | ||
+ | canvas._tkcanvas.create_image(0,0, image=photo, anchor = tk.NW ) | ||
+ | |||
+ | # wait and respond to events, or comment out and make the program | ||
+ | # stop as soon as car disappears. | ||
+ | win.wait() | ||
+ | win.close() | ||
+ | |||
+ | main() | ||
+ | </source> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | |||
+ | ===A Skeleton Event-Driven Program=== | ||
+ | <br /> | ||
+ | <source lang="python"> | ||
+ | # A Skeleton event-driven program | ||
+ | # D. Thiebaut | ||
+ | # | ||
+ | |||
+ | from graphics111 import * | ||
+ | |||
+ | MAXWIDTH = 800 | ||
+ | MAXHEIGHT = 800 | ||
+ | |||
+ | def mouseEvent( win, canvas, x, y ): | ||
+ | global menu | ||
+ | |||
+ | button = menu.buttonClicked( x, y ) | ||
+ | |||
+ | if button == None: | ||
+ | return | ||
+ | |||
+ | if button == "LeftArrow": | ||
+ | return | ||
+ | |||
+ | if button == "RightArrow": | ||
+ | return | ||
+ | |||
+ | if button == "Minus": | ||
+ | return | ||
+ | |||
+ | if button == "Plus": | ||
+ | return | ||
+ | |||
+ | |||
+ | # ======================================================== | ||
+ | # Main Program | ||
+ | # ======================================================== | ||
+ | def main(): | ||
+ | global menu | ||
+ | |||
+ | # open the window and get access to its canvas | ||
+ | win = GraphicsWindow(MAXWIDTH, MAXHEIGHT) | ||
+ | canvas = win.canvas() | ||
+ | canvas.setCallbackFunction( mouseEvent ) | ||
+ | |||
+ | # add a menu to the window | ||
+ | menu = Menu() | ||
+ | menu.draw( canvas ) | ||
+ | |||
+ | # wait and respond to events, or comment out and make the program | ||
+ | # stop as soon as car disappears. | ||
+ | win.wait() | ||
+ | win.close() | ||
+ | |||
+ | main() | ||
+ | </source> | ||
+ | <br /> | ||
+ | |||
+ | ==Graphics Library used in Textbook== | ||
+ | <br /> | ||
+ | * It is available for download [http://bcs.wiley.com/he-bcs/Books?action=resource&bcsId=8083&itemId=1118626133&resourceId=31809 here]. Once downloaded, unzip it and move it to the directory where you are developing your programs. | ||
+ | <br /> | ||
+ | |||
==All Demo Programs== | ==All Demo Programs== | ||
<br /> | <br /> | ||
* A selection of programs created in class can be found [[CSC111 Programs Written in Class 2014| here]] | * A selection of programs created in class can be found [[CSC111 Programs Written in Class 2014| here]] | ||
<br /> | <br /> | ||
+ | |||
==On Line Python books== | ==On Line Python books== | ||
<br /> | <br /> |
Latest revision as of 16:35, 10 May 2014
--D. Thiebaut (talk) 09:58, 7 January 2014 (EST)
Contents
Prof and TAs
Dominique Thiébaut email |
|
To see when and where TAs are available this week, click here.
Weekly Schedule
First Half (Feb-Spring Break)
Week | Topics | Reading |
Week 1 1/27 |
x = 3 name = "hello"
|
|
Week 2 2/3 |
|
|
Week 3 2/10 |
|
|
Week 4 2/17 |
(advance the movie to 7 minutes and 10 seconds)
|
|
Week 5 2/24 |
file = pickAFile()
sound = makeSound( file )
blockingPlay( sound )
|
|
Week 6 3/3 |
|
|
Week 7 3/10 |
No Quiz this weekend (3/8, 3/9)!
Youyou's cats, created during Lab 7 Session 1
|
|
Spring Break
Second Half (Spring Break-May)
Week | Topics | Reading | ||||||||||||
Week 9 3/24 |
|
| ||||||||||||
Week 10 3/31 |
|
| ||||||||||||
Week 11 4/7 |
|
| ||||||||||||
Week 12 4/14 |
|
| ||||||||||||
Week 13 4/21 |
|
| ||||||||||||
Week 14 4/28 |
>>> dict = {} >>> dict = { "apple":1, "pear":3, "banana":6 } >>> dict >>> dict[ "pear" ] >>> dict[ "orange" ] >>> dict[ "kiwi" ] = 12 >>> dict.keys() >>> dict.values() >>> dict.items() >>> for key in dict: print( key ) >>> for key in dict: print( key, dict[key] ) >>> contacts = {} >>> contacts[ "Marie" ] = "111 22 33" >>> contacts[ "Alex" ] = "222 33 44" >>> contacts[ "Francis" ] = "333 44 55" >>> contacts.pop( "Alex" )
|
|
Links and Resources
Map of Smith College
Full Map
Reduced Map
Dates of Construction for Smith Buildings
- The dates for the construction of different buildings on campus are available here
A Skeleton Python Program for Displaying An Image
# Skeleton program for displaying a gif image.
# D. Thiebaut
# Warning: will not work with a jpg or png image! If you
# need to convert your image to gif, use a Web service.
#
from graphics111 import *
import tkinter as tk
MAXWIDTH = 800
MAXHEIGHT = 600
# ========================================================
# Main Program
# ========================================================
def main():
gifFileName = "SmithMapSmall.gif"
# open the window and get access to its canvas
win = GraphicsWindow(MAXWIDTH, MAXHEIGHT)
canvas = win.canvas()
# put gif image on canvas
photo = tk.PhotoImage( file=gifFileName )
canvas._tkcanvas.create_image(0,0, image=photo, anchor = tk.NW )
# wait and respond to events, or comment out and make the program
# stop as soon as car disappears.
win.wait()
win.close()
main()
A Skeleton Event-Driven Program
# A Skeleton event-driven program
# D. Thiebaut
#
from graphics111 import *
MAXWIDTH = 800
MAXHEIGHT = 800
def mouseEvent( win, canvas, x, y ):
global menu
button = menu.buttonClicked( x, y )
if button == None:
return
if button == "LeftArrow":
return
if button == "RightArrow":
return
if button == "Minus":
return
if button == "Plus":
return
# ========================================================
# Main Program
# ========================================================
def main():
global menu
# open the window and get access to its canvas
win = GraphicsWindow(MAXWIDTH, MAXHEIGHT)
canvas = win.canvas()
canvas.setCallbackFunction( mouseEvent )
# add a menu to the window
menu = Menu()
menu.draw( canvas )
# wait and respond to events, or comment out and make the program
# stop as soon as car disappears.
win.wait()
win.close()
main()
Graphics Library used in Textbook
- It is available for download here. Once downloaded, unzip it and move it to the directory where you are developing your programs.
All Demo Programs
- A selection of programs created in class can be found here
On Line Python books
- disocovermagazine.com blog. Check out the answers posted by many readers. They contain some interesting links that you may find useful!
Python keywords
- The list of all the reserved words of the Python language
- and del for is raise assert elif from lambda return break else global not try class except if or while continue exec import pass yield def finally in print
Linux
- Getting Started with Linux (from U. North Carolina, Chapel Hill)
- Intermediate Linux (from U. North Carolina, Chapel Hill)
- A good Emacs tutorial
- Emacs Quick Reference
Misc
- If you decide to work in pairs for the homework assignments, you need to follow the protocol for 'pair programming' as discussed in this article.
- Video talks on Python:
- All the programs of Zelle's Python textbook
- a video of digital horses: what we can do with lists of objects!
Software
- Installing and using the Secure Shell Client on a Windows PC.
- Using SSH on Windows, Linux, or on a Mac with OS X
Class Videos
(The tables below were generated by this Python program.)
Back To Main Page