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, 22.06.2019 03:50
You are working as a security analyst in a company xyz that owns the whole subnet range of 23.0.0.0/8 and 192.168.0.0/8. while monitoring the data, you find a high number of outbound connections. you see that ip's owned by xyz (internal) and private ip's are communicating to a single public ip. therefore, the internal ip's are sending data to the public ip. after further analysis, you find out that this public ip is a blacklisted ip, and the internal communicating devices are compromised. what kind of attack does the above scenario depict?
Answers: 3
question
Computers and Technology, 23.06.2019 18:00
While inserting images, the picture command is usually used to insert photos from a digital camera, and the clip art command is usually used to a.edit the sizes and other characteristics of photos that have been inserted. b.take a screenshot of an image and copy it to the clipboard for pasting. c.search for drawings or other images from a library of prepared pictures. d.make illustrations using lines and shapes that are easy to manipulate.
Answers: 1
question
Computers and Technology, 24.06.2019 04:10
Write a program that reads a set of floating-point values. ask the user to enter the values, then print • the average of the values. • the smallest of the values. • the largest of the values. • the range, that is the difference between the smallest and largest. of course, you may only prompt for the values once.
Answers: 3
question
Computers and Technology, 24.06.2019 07:00
Selective is defined as paying attention to messages that are consistent with one’s attitudes and beliefs and ignoring messages that are inconsistent.
Answers: 1
You know the right answer?
Write a class that represents and defines operators for Interval numbers, which are represented by a...
Questions
question
Mathematics, 08.03.2021 19:40
question
English, 08.03.2021 19:40
Questions on the website: 13722361