The Artima Developer Community
Sponsored Link

Python Answers Forum
Python program question

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Parth Patel

Posts: 1
Nickname: p2only4u7
Registered: Dec, 2007

Python program question Posted: Dec 3, 2007 7:45 AM
Reply to this message Reply
Advertisement
Hi everyone I m new in this program and I have this project which could matter me pass and fail so if u could please help me out I would appreciate because I have no clue how to start.
Well the program is an arithmetic interval the question is this:

The goal of this project is to develop a class to perform elementary interval arithmetic. Interval
arithmetic was developed as an approach to put bounds on rounding errors in mathematical
computations as a way to obtain reliable results.
For two intervals [a; b] and [c; d], the basic arithmetical operations are de¯ned as
[a; b] + [c; d] = [a + c; b + d]
[a; b] ¡ [c; d] = [a ¡ d; b ¡ c]
[a; b] £ [c; d] = [min(ac; ad; bc; bd); max(ac; ad; bc; bd)]
[a; b] = [c; d] = [min(a=c; a=d; b=c; b=d); max(a=c; a=d; b=c; b=d)]
In this project you will de¯ne a class Interval and use operator overloading to implement the
four basic arithmetical operations on intervals.
If we store the class de¯nition in the ¯le interval.py, then an interactive session might run as:
>>> from interval import *
>>> x = Interval(3)
>>> x
[3.000000,3.000000]
>>> y = Interval(2,4)
>>> y
[2.000000,4.000000]
>>> x + y
[5.000000,7.000000]
>>> x - y
[-1.000000,1.000000]
>>> x * y
[6.000000,12.000000]
>>> x / y
[0.750000,1.500000]
Observe the value of the default right end point of the interval and the representation of intervals.
Some important points:
1. You must ensure that Python stores the end points of the interval as °oats, otherwise the
division might yield unexpected results for integer end points.
2. Provide proper documentation, i.e.: every function must have a documentation string.

Topic: win32all+vista Previous Topic   Next Topic Topic: Verify PKCS7 against CA hierarchy

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use