[Skip to Body]
Primary:
[Front Door]
[Schedule]
-
[Academic Honesty]
[Instructions]
Current:
[Outline]
[EBoard]
[Reading]
[Lab]
-
[Assignment]
Groupings:
[Assignments]
[EBoards]
[Examples]
[Handouts]
[Labs]
[Outlines]
[Project]
[Readings]
Related Courses:
[CSC223 2007F (Davis)]
[CSC223 2004F (Rebelsky)]
Misc:
[SamR]
Assigned: Tuesday, February 2, 2010
Due: 1:15 p.m., Thursday, February 4, 2010
This assignment is also available in PDF.
Summary: In this assignment, you will further explore the Python programming language.
Purposes: To encourage you to explore a bit more Python.
Expected Time: Two to three hours.
Collaboration: You may work in groups of up to size four. You may also work individually. You may talk to whoever you wish about this assignment, provided you cite appropriately. I would prefer that you not search for answers on the Internet.
Submitting: Email
me your answers. Use a title of CSC 323: Assignment 2
.
Warning: So that this assignment is a learning experience for everyone, I am likely to spend class time publicly critiquing your work.
A. Implement binary search in Python. You should write a procedure,
binary_search(i,vals)
, that takes as input an integer
and a list of integers, sorted in increasing order. Your procedure
should return an index of i
, assuming i
appears in vals
. If i
does not appear in
vals
, your procedure should return -1.
B. Create a simple Fraction (Rational number) class in Python. Your goal in creating this class should be to make sure that you understand the various methods you can define and override. Your code should provide reasonable answers to expressions like the following:
>>> x = Rational(1,3) + Rational(1,2) >>> print(x) 5/6 >>> Rational(1,3) < Rational(1,2) True
[Skip to Body]
Primary:
[Front Door]
[Schedule]
-
[Academic Honesty]
[Instructions]
Current:
[Outline]
[EBoard]
[Reading]
[Lab]
-
[Assignment]
Groupings:
[Assignments]
[EBoards]
[Examples]
[Handouts]
[Labs]
[Outlines]
[Project]
[Readings]
Related Courses:
[CSC223 2007F (Davis)]
[CSC223 2004F (Rebelsky)]
Misc:
[SamR]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Tue Feb 2 15:57:47 2010.
The source to the document was last modified on Tue Feb 2 15:57:46 2010.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CSC323/2010S/Assignments/assignment.02.html
.
You may wish to
validate this document's HTML
;
;
http://creativecommons.org/licenses/by-nc/2.5/
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.