Physics 165

Introduction to Programming for the Physical Sciences

University of Maryland
Course Information
Syllabus Assignments
Mac Users
Submitting Programming Problems
 Synopsis of Material Covered
Solutions to Programming assignments
Programming Evaluation Criteria
Programming Projects # 1 and  2
Sample Problems for Exam # 1 and 2
Final Exam Date

Course Information

The course will cover basic programming skills using examples from the physical sciences.  The course prerequisite is one semester of a calculus-based physics course such as Phys 141, 161 or 171, or credit on the physics AP exam.  The language used is Python, which is an interpreted, object-oriented language with both scripting and systems level capabilities.  The course will provide instruction in the standard programming techniques used in upper-level languages such as Fortran, C, and Pascal, as well as an introduction to the object oriented programming techniques used in languages such as C++ and Java.  The course will include a strong component of visualization and graphing using the visualization tools available through the VPython* implementation.

*The Visual library is Copyright (c) 2000 by David Scherer.

Outline of Course Material    (subject to modification as the class progresses)

Introduction to VPython (documentation, demo programs)
     Physics units in computation
     Visual display - modifying and documenting demo display program
Number types, mathematical operations, lists
     Visual display - static objects, using lists, screen I/O
Numerical Solutions of Differential Equations
      Newton's laws
      Programming exercise - following the effect of varying dt in Euler method
Logical Expressions (while, for)
      Kinematics, orbits
      Application in numerical solutions
Logical Expressions (if, else,then)
      Visual display - incorporating control commands in dynamic display
Designing a program, data files
      Begin first programming project
      Visual display - program control of object characteristics
User defined functions
      Speed of sound in a solid
Two-dimensional arrays (list of lists)
      Multi-body forces
     Conservation of Energy (springs, dissipative forces)
Physics Simulation, random number generator
      Two-dimensional random walk
      Calculating averages and distribution functions
      Begin 2d programming project
Data Files, String operations
Classes, Methods, Inheritance, Operator overloading
Screen interactions, time


back to top
Physics 165 - Introduction to Programming for the Physical Sciences

Instructor:  Professor E. Williams
Room 2332 Physics,
Phone 405-6156,
for help with class:  phone, e-mail or see me after class to make an appointment

Class Location:
M W 3:00 PM, Room 1201 Physics
F 3:00 PM, Room 3115 Physics (POWL)

Course Software:  Python and VPython*

The software is installed and available for use in the Physics Open Workstation Laboratory (POWL), room 3115 Physics Bldg.  If you wish to install a copy of the software on your personal computer, it is available as freeware at: .

*The Visual library is Copyright (c) 2000 by David Scherer.

Textbooks:     Learn to Program Using Python, A. Gauld, Addison-Wesley, 2001

 Matter and Interactions, Vol. I, R.W. Chabay and B.A. Sherwood, Wiley, 2002.
See course information for a detailed outline of material to be covered
Chapters 5-20, Gauld; (not all material in each chapter will be covered)
Chapters 1-3 and selected topics in 4-12, Chabay and Sherwood
Learning Python, M. Lutz and D. Ascher, O’Reilly, 1999
VPython Reference Manual, R. Chabay, D. Scherer, and B. Sherwood
Python Tutorial,  G. van Rossum, F.L. Drake, Jr.
Course Requirements
1. Homework, 1 set per week, due Fridays at the beginning of class.
2. Programming Projects:   Due mid-october (due-date to be announced), and Dec. 17.
3. Practical Exams:   Friday, Oct. 5;  Wednesday, Nov.28
4.Final Exam - presentation of final project:  Monday, Dec. 17, 8:00-10:00 AM
Homework: 20%
Programming Projects:  50%
Exams 30%
Academic Honesty
Working together on assignments is encouraged.  However, each student is expected to do the assigned problems and write the assigned programs independently, and hand in his or her own work for grading.  For any questions about academic honesty, see University policies at: .
back to top
 Course Logistics:

We will have class in the Workstation Lab (room 3115 Physics) every Friday, and possibly on other dates to be announced as well.  Make sure you always bring PC-formatted floppy disks to the Lab (both for classes there and when you are working on assignments there) so that you can save your work.  There are a large number of demonstration programs available on the server.  You are welcome to copy these to study and to edit to create new programs.

The programming projects and most homework assignments will require creation of computer programs.  You will submit these by copying them onto a PC-formatted floppy disk, and turning in the disk. If I can’t read the disk or open the program files using VPython, the grade for the assignment will be zero.  So make sure the disk is functioning properly before you hand it in!  The disks will be returned to you (with contents) after grading, but you should maintain your own back-up library of disks containing all the programs you have created.  On a trial basis (while I determine if this creates too much chaos), you can send me program files as attached documents in an e-mail.  I will NOT look at such files unless:
      1)   The subject line on the e-mail is "Physics 165 Assignment from <yourname>"
      2)   The listing of the program is pasted into the e-mail body as text.
      3)   The title of the file is "<yourname><A#><P#>.py"

   For example "" would be problem three from assignment two, handed in by Williams.
Finally, as with submission on floppy disk, it is your responsibility to make sure the file reaches me in a form that works.  You should test this in advance by exchanging files with a friend.

Successful programming requires rigorous logic and a lot of organization.  To keep your work organized I strongly recommend that you purchase a three ring binder, tabbed dividers, and disk envelopes and use these to store all of your course work, class notes, and the documentation that you download.  You should also create an annotated index of all the files that you create, and organize the files on your disks with self-evident names in a logical structure of folders.  Your python files can also be printed (for storage in your ring binder and easy reading) by copying the text from the IDLE window and pasting it into the editing/word processing program of your choice (e.g. bbEdit, Word…).

back to top
Solution Sets

Programming solutions to the assignments will be posted on the Delphi network, which you can access from the POWL lab.  The location of the solutions (and occassional other miscellaneous information) will be found on the drive "Course on Delphi\Groups(P:), in the folder P165.

back to top
(listed in reverse chronological order)

Problem Set 8:   Due Monday, Dec, 10

Reading:   Gauld, Ch. 16 and 17
                Downey, Ch. 11-14, 16
                Python Tutorial, Ch. 9

1. Exceptions:  Write a short program to input two numbers from a file, divide the first number by the second, and output the result to the screen.  Include an error handling sequence to catch (and print appropriate messages for) three types of errors:  an IO error if the file cannot be opened, a value error if the input values can’t be converted to a numeric type, and a divide by zero error.  See section 2.2 of the Python Library Reference for exception names, and section 9.3 of the Python tutorial for examples.

2. Define a class called Polarvector that creates three-component vectors in spherical-polar coordinates.  Your class should:
a)  have attributes r, theta and phi, with theta and phi to be specified in radians
b)  allow class objects (instances) to be defined with user-chosen initial values for r, theta and phi
c)  have 4 methods that return respectively the x, y and z components of the vector, and a three-element list containing the three components

3. Define a subclass, Dpolarvector to your class Polarvector.  The sub-class will allow you to define theta and phi in degrees.  Your definition should introduce new attributes thetad and phid, but allow you to use the original methods of the class Polarvector.

back to top
Assignment # 7  Histograms, averages, files
Reading:     M&I, Ch. 11, for random walk see Section 11.6 (p. 404-405)
                   Gauld, Ch. 12 and 14
                   For additional description and examples see:  (histograms)  (files and exceptions)
Programming Assignment:  Due Wednesday, Nov. 21

Problem 1:  Write a function to create a probability distribution given a list of numbers.  Your function should use the special list functions, len, sort, max, and min.  Your input should be only the list and the number of "bins" desired ? your function should define the bin size and range from the properties of the list.  Your program should output the distribution as a four?element list (or tuple) containing 1.  minimum value of the range, 2.  bin width,  3.  number of bins in the distribution, 4.  the distribution as a list.  I will (soon) post some test lists that I will use as inputs to check that your function works correctly.  (Option:  you can make your function more useful by putting in a default option to input bin width and origin of range, or to use the automatic determination based on list properties.)

Problem2:   Modify the random walk program developed in class (see on course server) to calculate and display the average (over at least 50 walks) root mean-square displacement vs. step number.  Also tabulate (for each walk) the root-mean-square displacement after 30 steps, and either display your result as a histogram (using histogram graph) or use your histogram function from part 1 to 1 to make a neatly formatted column output of the distribution.

Problem 3:  Write a function to output a n x m list (n columns, m rows) to a file in a format that can be pasted into a spreadsheet.

Problem 4:  Write a program to read from the data file "table.doc" ( on course server) and create a numeric list (or two lists) representing the saturated vapor density (in g/cm^3) vs. the temperature (in degrees C).  You will need to look at the original table on the web site  (use the index and choose vapor pressure) to see how the text file represents the tabulated values.  I will test your program on the original "table.doc," so don’t edit the file to make the input easier!

back to top
Assignment # 6  Multi-body calculations, nested lists, random #’s, files
Reading:  M&I Section 3.5 (speed of sound in a solid)
                M&I, Section 4.4.8 (P. 132), 4.6.2 (p. 141-142), Section 11.6 (p. 404-405)
                Gauld, Ch. 12
                 For additional description and examples see:
       (section 8.12 - nested lists)

Programming Assignment:  Due Friday, Nov. 2

Problem 1:  Write a program to calculate the speed of propogation in a 1-dimensional chain of atoms as in M&I, problem 3.6 (p. 109-110).  Define and use at least one function in your program.  Your program should calculate the total energy for your starting configuration, and then update the total energy at each step in your numerical solution of the equations of motion, and confirm that the energy is conserved for your choice of the time increment.  Your program should also compare your numerically calculated speed of sound with the formula described in the text.

Problem 2:  Write a function to to create an nxm array and fill it with zeros.  Use the function in a program to generate and print out (in neat array format) all the force pairs in a group of five atoms interacting via a Morse Potential (see p.142 of M&I) with  req = 0.25 nm, a = 0.2 nm-1, and Eo = 3.0x10-19 J .  The five atoms should be located at positions:   r = 0, req, 2 req, 3 req, 4req.  The program should also calculate the net force on each atom and print out the result in neat column format.

Problem 3:  Finish problem 4 from PS. 5 - you might want to define a second function for updating cylinder position in response to the spheres moving.  This is more efficient (of computer time) than using the creation function alternating with the erase command (cylindername.visible=0).

back to top
Assignment # 5  Introduction to Functions
Reading:   Gauld, Ch. 11 p. 77-83
                 For additional description and examples see:
         (sections 5.1 through 5.3)

Programming Assignment:  Due Friday, Oct. 19

Problem 1:  Write two functions to find the roots of the quadratic equation a*x**2 + b*x + c = 0.  The first function should output the roots as a tuple, the second should ouput the roots as elements 0 and 1 in a list.  Write a test program that reads in values for a,b and c, and uses each of your functions to find the roots, and prints the roots calculated with each function.   (Be careful ? if you enter the values of constants and  a, b and c as integers you may get strange results.)

Problem 2:  Write a function to provide a list of Physics constants (choose at least 5 and enter them with at least three significant digits each) as global variables.  Write a test program that uses your function to create the variables and prints the values of the constants in a documented list.

Problem 3:   Write two functions that provide the elements of an Euler calculation as follows: The first function should calculate the gravitational force given the values of two masses and their positions.  The second function should output updated values of position, velocity and acceleration given a time increment dt and initial values of position, velocity and accleration.  Write a test program that uses the force function to evaluate the gravitational force and compares the result to a known value.  Write another test program that uses both functions (you can call the first function from the second function) to do one step of an Euler iteration and compare the output to a known result.

Problem 4:  Write a function to draw a cylinder (visual graphic object) between two spheres.  The input to the function will be the spheres’ positions, radii, and color.  You should make the cylinder’s position such that it appears to connect the two spheres, and you should make the cylinder’s radius and color depend on some logical combination of the radii and colors of the spheres.  Write a test program that uses your function in creating a display of three spheres and two cylinders.  Have the program vary the properties of one of the spheres.  Does your cylinder change as the sphere properties change?  Why or why not?  Document this and other properties of your function in your function definition.

back to top
Assignment 4
Reading:    Gauld, Chapters 8 and 9 (do all the exercises in the text as you read)
                  M&I, Ch. 3,   Sections 3.4.8 through 3.4.13

Problem set:  Due Friday Sept. 28

Problem 1:  Write a program (modifying an existing program, such as, is fine) to solve the equation of motion for a 1-d Hooke's law force (F(x) = -kx) numerically.  Your program should

-  document your physical system
-  loop the analysis over variable values of the time increment
-  compare the numerically calculated value of the period of oscillation with the
    analytical value for each time increment tested, and print the result
- end the loop when the result is accurate to within 0.1% and output the final results

Problem 2:  Write a program to determine how many months it takes to pay off the purchase of a $1000 stereo system on credit.  The purchase agreement was:  no down payment, an interest rate of 18% per year (and hence 1.5% per month) and monthly payments of $50.  The monthly payment is used to pay the interest due for that month and whatever is left after that is used to pay part of the remaining debt.  Hence the first month you pay 1.5% of $1000 in interest - that is $15.  So the remaining $35 is deducted from the debt, leaving a debt of $965.  The next month you pay interest of 15% on the remaining $965, and etc.  (The last payment may be less than $50.)  Your program should determine the interest and principle paid each month, and the total interest paid over the course of the loan, and output that information along with the duration of the payments.

Problem 3:  Try the three segments of code below (available in course folder as in case you don't want to retype them - remember the indentation is VERY important) and make sure you understand exactly what each one is doing.  Then change (or replace) the code to accomplish two new outcomes:
a)  to list all the factorizations for each number (e.g. 2*4 and 4*2 for 8).
b)  to list all the unique factorizations for each number (e.g. 2*4 only for 8, but 3*4 and 2*6 for 12).
Test your program to make sure it works for larger ranges.  Grading on this problem will be based on whether the programs work (for any range) and length of code (shorter is better).  Limited documentation is needed.

for n in range(2,13):
    for x in range (2,n):
        if n%x = = 0:
            print n, "equals", x, "*",  n/x
            print n, 'is a prime number'
print "the program is done"

print "\n second trial program \n"
for n in range(2,13):
    for x in range (2,n):
        if n%x = = 0:
            print n, "equals", x, "*",  n/x
            print n, 'is a prime number'
print "the program is done"

print "\n third trial program \n"
for n in range(2,13):
    for x in range (2,n):
        if n%x = = 0:
            print n, "equals", x, "*",  n/x
    print n, 'is a prime number'
print "the program is done"

back to top
Assignment 3
Due:  Wednesday Sept. 19

Reading:   M&I, Ch. 2, sections 1-6
                 Gauld,  Ch. 6, through p. 46, Ch. 7 through p. 58, p. 61-2

1.  Complete the program discussed in class on Sept. 7.

Program requirements:

Display a set of N spheres equally spaced around circumference of a circle of radius R.

 Read in the values of N and R from the screen
 The coordinates should be calculated and stored in a list using a For command.
 Output the list of x-y coordinates to the text display screen.
 Display the positions of the spheres on a visual display screen.
2.  Problem 2.15.1 (a-e) in M&I

You will hand in both the program file, and a written answer to part a and b and the answers to the questions in parts d and e.  You may wish to use the demonstration program as a starting point for creating your program

Program requirements:

Program to calculate the orbit given an arbitrary input of initial speed, using numerical solution of the equations of motion.

 Write the optimum time interval value and the initial speed value for a circular orbit to the output screen.
 Read in the values of the time interval and the initial speed to be used in running the program from the output screen.
 Calculate the orbit using the numerical method described in section 2.6.3.
 Display the x-position and the x-component of the force vs. time in a graphical display window.
 Display the orbit in the visual display window.
back to top
Assignment 2
Due: Friday Sept. 7

 VPython Documentation:  Introduction
 Gauld, Ch. 6 through p. 46, p. 56-7, and p. 73-4
 Chabay and Sherwood, Chapter 1, section 11 (Example Problem)

Problem Set:

1. Write a program to read in TWO values of radius from the screen, calculate the area and circumference of a circle for each radius, and print out the answers.

2. Problem 1.3 from Matter and Interactions.  Use a scene display for parts a-c and a graph display for parts d,e.  It is fine to edit any convenient demo programs for this problem.

Note 1:  In all programming assignments, clear documentation within the program and clear input/output messages (as discussed in class) are required.  Remember to documents the UNITS being used for all the quantites in your program.

Note 2:  Remember - Python is case sensitive:  print is not the same command as Print.  Also, Python program file structure is sensitive to indentation.  We’ll learn more about that soon.  For now, just keep your command lines left justified unless you are inside a control loop.

Note 3:  It appears that e-mail submission of program files works.  I will confirm and document method in class on Wed. Sept. 5.  As with submission on floppy disk, it will be your responsibility to provide me with a file that works the first time I try to open it in Python.

back to top
Assignment 1
Due:  Friday, August 31

Follow the step-by-step demonstration instructions in Ch. 5 of Gauld.
Save the results to disk and hand in the disk.

Getting the mechanics working to do the assignment:

This is an introduction to using Python.  It can be done in the POWL lab, or on your own computer if you have installed the software.

Double click the Vpython icon and the IDLE window opens

Go to the menu bar and pull down "run" to "python shell"

Python Shell window opens.

Follow instructions in Ch. 5 - don’t worry if everything doesn’t make sense, this assignment is primarily to get a feeling for using the software

Note that 4 of the commands printed in the "string format codes" box in the book are incorrect - they are missing the symbol % after the first quotation mark.

Use the save as command (found under file on the menu bar) to save what you are doing to a file on your floppy disk.  Name the file

Do a last save before executing the command "sys.exit()" on page 34.

back to top

Programming Projects

Programming Project #1:   Due Monday, October 22
                                      Topic approval, no later than Sept. 28
                                       Approach approval no later than Oct. 8

Assignment:  Choose a physical science problem amenable to computer-based analysis and write a program to solve that problem.

Program Specifications:  The program should illustrate your ability to do the following:

a)  create and use lists
b)  use control statements effectively (for, while, if..else)
c)  solve Newton's equations of motion numerically
d)  create and use effective input/output screens, including graphics
e)  design and use test cases to insure the correct functioning of your program
To do an interesting problem will probably require about 50 lines of code (documentation statements don’t count as lines of code).  The maximum length should not be more than 100 lines of code.

Problem Choice:     You should choose a problem where you can illustrate some effects that are not easy to generate analytically.  Topics from Chapters 2 and 3 of M&I would be a good choice.  You can get some ideas from the problems in the book (or from other books on physical science).  Examples of reasonable problems would be;  projectile launch to orbit, orbital motion with three bodies, pendulum outside of harmonic approximation, simple harmonic motion with friction….  You must discuss your plan for your project with me, and get approval of the topic.

Programming Approach:  Use the 6 steps of software development :

 1)  Specify the problem requirements (and see me for topic approval)
 2)  Analyze the problem
 3)  Design the algorithm (and see me for approach approval)
 4)  Implement the algorithm
 5)  Test and Verify
 6)  Document thoroughly
Programming Project #2:   Due Monday, Dec, 17, 8:000 AM

Assignment:  Choose a physical science problem that involves either multiple interacting objects, or stochastic processes, and write a computer program to calculate the behavior of the system and display the results effectively.  Your program output should make it easy for the user to understand your problem and the significance of the result.  You should clearly indicate at least one independent variable in the problem, document the effects of changing the values for that variable in the program and explain the significance of the result.  .
 For your final exam grade, you will describe and demonstrate your program in a 10-15 minute presentation for the class during the final exam period.

Program Specifications:
The program should illustrate your ability to do the following:
a)  define and use functions
b)  define and use classes and associated methods (use at least one)
c) use multi-dimensional lists and nested loops (for many-body problem)
 Calculate statistical averages and distributions (for stochastic problem)
d)  create and use effective input/output screens, including graphics
e)  design, use and document test cases to insure the correct functioning of your program
To do an interesting problem will probably require about 50-100 lines of code* (documentation statements don’t count as lines of code).  The maximum length should not be more than 150 lines of code.

Programming Approach:
Use the 6 steps of software development :
 1)  Specify the problem requirements (and see me for topic approval)
 2)  Analyze the problem
 3)  Design the algorithm (and see me for approach approval)
 4)  Implement the algorithm
 5)  Test and Verify
 6)  Document thoroughly and CLEARLY

*If you modify an exisiting demo or course program, you should clearly indicate with documentation statements what part of the code is original (e.g. you wrote it) and what parts of the code came from other sources.

back to top

In-Class Exams

Exam #1
Exam will be a practical programming exercise, held in the POWL lab.

Exam Rules:

Blank floppy disks will be provided.
Students may use any documentation or files on the course server.
Students may not use books, notes or any contents of their own floppy disk.
Exam Format:
Students will be asked to write a Python program that
   a)  creates a list or lists
   b)  fills the lists with numbers using a prescribed algorithm
   c)  selects elements form the lists according to prescribed criteria
   d)  reports the results in a prescribed format
Sample Exam Problem:
Create a list of the values of f(x) for x from 0 to 51 in increments of 3, where
   f(x) = 36x for odd values of x
   f(x) = x**2 - 1206 for values of x that are multiples of 4
   f(x) = x**2 for all other values of x
Find the values of x for which f(x) is greater than 300 and divisible by 18
Print x, f(x) in column format for these values of x.
Exam #2
Same exam rules as Exam #1

Exam Problem:

The problem will be similar to Problem 2 on Problem Set # 6.  You will be given a force function and the positions of a certain number of point-particles and asked to calculate all pair-wise forces, and the net force on each particle.  The difference from the previous problem is that the particle positions will cover a two-dimensional space.  The solution program from Problem Set #6 will be available on the course server for this exam.
back to top

Synopsis of Material Covered

I will periodically make a list of the material we have covered in class and assignments and post it here.  Posting will be in reverse chronological order.

Dec. 10, 2001

Updates on documentation:

Python Library Reference:

 Section 2.2,  Built-in Exceptions
 Section 3.10, Standard operators as functions
 Section 3.18, Copy and deepcopy
 Section 6.9, Time module
Python Tutorial
 Section 7.2  Reading and Writing Files
 Section 8.2-6  Errors and Exceptions
VPython:  Mouse Interactions

Programming Topics

 Reading and Writing Files
    Functions for string manipulation
    Opening files for read and/or write
    Read and write commands
    Dealing with external file formats
    Pickle module

    Try, except

     Attributes: definition, attribute initiation
     Methods: definition, modifier methods
     Names space issues, mutability
     Class definitions including previously defined classes
     Inheritance, definition of derived class
     Copy, deepcopy
     Operator overloading

 Interactions with user/external world
     Time module
     Mouse clicks and position

Nov. 2, 2001

Updates on documentation:

ASCII Codes (file asciilist.doc)

Python Library Reference:
      Section 2.1.2-2.1.5,  Boolean Operations, Comparisons, Sequence Types
      Section 2.1.7, p. 14-16, File Objects
      Section 2.3  Built-in Functions
      Section 5.3  Math Functions
      Section 5.4  Complex Math Functions

October 24, 2001

Updates on documentation:

VPython:  Cylinder, Histogram
Listings of:
                      Your programs and functions
                      class examples (hole-in-the,
                      solution programs

Physics Topics:

 Central force, unit vector
 Spring force, boundary conditions
 Multibody system forces
 Multibody system potential energy
 Statistical averages and distribution functions
Programming Topics:
 Program control via loops (for, while)
 Program control via branches (if, elif, else)
 Nested loops and branches
 Program control of color, object characteristics in graphics
 Program control via functions
           Defining, inputs, global vs. local variables, outputs
 Variables assignment
           Names vs. object location
           Mutable list operations
           Variable swapping
 2-D arrays (lists of lists)
           indexing, creating, filling
 Random numbers
Sept. 17, 2001

Additions to documentation in your notebooks should include:
   VPython reference pages for:  Curve,  Vector,  Graph Plotting,  Controlling Windows
    listings of :
            #   demo program,
            #   your programs
            #   class example (, solution programs

Topics covered:
   #  creating and filling lists, list operations
   #  using range and arange operators
   #  for loops
   #  Create visual display
   #  Create a graphical display
   #  formatting output to the Output window,  integer, real exponential forms
   #  good practices (evaluation criteria)
   #  numerical solution to F=ma  (Euler method)
   #  while loops

    #review central forces, vector math, orbits
    #Program control (for, while,  if  elif  else )
    #Programming project

September 5, 2001

#Documentation in your notebooks, should include at least:
#   VPython Introduction
#   Python Mathematical Functions Reference Document
#   VPython reference pages for "sphere" and "box"
#   Program listings for and
#   Course notes, practice programs from Friday class

#Key points covered in class/assignments to date:
#   Syllabus/web page
#   Finding documentation
#   Organizing for problem solving
#   Number types - integer, real, imaginary, (Boolean)
#   Using Python math functions, importing math module as needed
#   Formating real number display (%x.yf)
#   Documenting your programs, including UNITS on variables
#   Screen I/O
#   Using the VPython graphing display
#   Using the VPython screen display (3-D visualization)

#   Today:  Variables representing Sequences, Boolean expressions

back to top
Programming Evaluation Criteria

Possible Points
Per Program
Program 1
Program 2
Program 3
Title/name/date as first line in program 1 . . .
Units documented in program, numerical values defined as variables 5 . . .
Output screen display neat,
profesional, numbers include units, attention to significant figures
5 . . .
Graphical screen display(s) effective, and intuitive, properly scaled, labeled approropriately 5 . . .
Debugging points included in program, use of independently tested functions  5 . . .
Physical reasoning and programming steps documented  10 . . .
Test case used to evaluate program peformance, test documented 10 . . .
Program works as specified, required program elements included 20 . . .
Total Points . . . .

back to top

Mac Users

The installation for MacIntosh computers  is a two step process.  Before beginning, you should  open and print the Installation Instructions, so that you can follow them through the process.  First the Python module is downloaded and installed - this is a big installation job, so be patient.  Then the Mac VPython module is downloaded. This creates a VPython folder, containing folders and files that must be moved into the Python folder.  If you are running OS 9.0 or older, you should be ready to go.  You can test whether things are working by dragging one of the demo programs (look in Program folder, Demo sub-folder) and dropping it onto the PythonInterpreter icon.
If you are running an OS version later than 9.0, double-click the ConfigurePythonClassic icon, and you should be ready to run.

The Mac version doesn't have an IDLE window environment like the PC version.  Instead you need to use an editor (like BBEdit Lite ( to create and edit Python files.  Python files can be opened by just dragging them onto the BBEdit icon.  Then to run your program, just save and drop your python file icon onto the interpreter.  This is really only slightly less convenient than working in the IDLE window.

I’ve confirmed that I can move Python files back and forth between Mac and PC.  If you are handing in files on a floppy disk, make sure it is PC formatted and check out that your files really can be read on a PC by trying them in the POWL before handing it the disk.

back to top

Copyright (2001) University of Maryland, College Park. All rights reserved. 
Permission to redistribute the contents without alteration is granted to
educational institutionsfor non-profit administrative
or educational purposes if proper credit is given to
the University of Maryland, College Park as the source.