subject
Computers and Technology, 25.10.2021 23:30 SMNS625

Write a class that represents and defines operators for Interval numbers, which are represented by a pair numeric values: int, float or mixed. We use intervals to represent approximate numbers, whose exact value we do not know. For example, in physics we might know that the acceleration produced by the the force of gravity (g) at sea level is 9.8 m/s2+/- .05 m/s2, which we will write as 9.8(+/-.05) m/s2. With this class we can perform numeric calculations on Interval objects, which automatically keep track of the precision for each calculated value For example, the formula sqrt(d/(2*g)) computes the amount of time it takes for an object at sea level to fall a given distance (d) in a vacuum. Given our approximation for g, and a distance that is 100(+/-1) m, we can use the Interval class to compute the amount of time it takes for an object to drop this amount as follows, including the precision with which we know the answer. Interval. mid_err(9.8,.05) Interval. mid-err(100,1) (d/(2*g)) . sqrt() d = t print(t) So, with g known +/-.05 m/s-, and d known +/-1 m, the results print as 2.258792382 6805945(+/-0.01 7056289680373204), which indicates that the time will be somewhere between about 2.24 and 2.28 seconds, having a relative error of about 7.6%. Note that each Interval object will store the minimum and maximum value in the interval. So 9.8(+/-05) is stored as an Interval with a minimum of 9.75 and a maximum of 9.85 Details
1. Define a class named Interval in a module named intervalpy
2. Define an init method that has two parameters: their arguments specify the minimum and maximum values in the interval respectively. Store them in the self variables min and max. Programmers will not use this method directly to construct Interval objects; instead, they will use the static Interval. min max and Intervalmid err methods (described below) For information about static methods, read the Class Review lecture notes (look for the entry on Static Methods near the bottom, before the problems)
3. Define a static min max method that has two parameters; their arguments specify the minimum and maximum values in the interval. The second parameter is optional, with None as its default value. This method should raise an AssertionError exception, with an appropriate message, if
(a) the first argument is not an int or float numeric type or
(b) if the second argument is not a numeric type or None, or
(c) the first argument is greater than the second; if the second argument is None, use the first argument for botłh the minimum and maximum value (creating an interval with one value representing exactly that number) Return the appropriate Interval object.
4. Define a static mid err method that has two parameters; their arguments specify the middle value and the +- error for the interval. The second parameter is optional, with 0 as its default value. This method should raise an AssertionError exception, with an approprate message, if
(a) the first argument is not an int or float numeric type, or
(b) if the second argument is not a numeric type, or
(c) if the second argument is negative. Return the appropriate Interval object. For example, Interval. mid err(9.8.05). would produce the same object as Interval. min max(9.75,9.85)

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:00
Signal sets company contracts to deliver one hundred 52-inch plasma high-definition television sets to a new retail customer, tuner tv store, on may 1, with payment to be made on delivery. signal tenders delivery in its own truck. tuner's manager notices that some of the cartons have scrape marks. tuner's owner phones signal's office and asks whether the sets might have been damaged as they were being loaded. signal assures tuner that the sets are in perfect condition. tuner tenders signal a check, which signal refuses, claiming that the first delivery to new customers is always for cash. tuner promises to pay the cash within two days. signal leaves the sets with tuner, which stores them in its warehouse pending its "grand opening sale" on may 15. two days later, tuner's stocker opens some of the cartons and discovers that a number of the sets are damaged beyond ordinary repair. signal claims tuner has accepted the sets and is in breach by not paying on delivery. will signal succeed on these claims? explain.
Answers: 1
question
Computers and Technology, 23.06.2019 04:00
Laire writes a letter to her grandmother, in which she describes an amusement park she visited last week. she adds pictures of that place in her letter. which feature of a word processing program will claire to remove unwanted parts of the pictures?
Answers: 3
question
Computers and Technology, 23.06.2019 19:00
Choose the correct citation for the case which established the "minimum contacts" test for a court's jurisdiction in a case. select one: a. brown v. board of education of topeka, 347 u.s. 483 (1954). b. international shoe co. v. washington, 326 u.s. 310 (1945) c. haynes v. gore, 531 u.s. 98 (2000). d. international shoe co. v. washington, 14 u.s. code 336.
Answers: 1
question
Computers and Technology, 24.06.2019 06:30
Some peer-to-peer networks have a server and some don't. true false
Answers: 2
You know the right answer?
Write a class that represents and defines operators for Interval numbers, which are represented by a...
Questions
question
Computers and Technology, 13.07.2019 06:10
Questions on the website: 13722367