Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

coding in python need help getting sub to work. For input: I1=Interval(1,4) I2=Interval(-2,-1) Want I1+I2 Ouput: [-1,3] import numpy as np import matplotlib.pyplot as plt

coding in python

need help getting sub to work.

For input:

I1=Interval(1,4)

I2=Interval(-2,-1)

Want I1+I2

Ouput: [-1,3]

image text in transcribed

import numpy as np

import matplotlib.pyplot as plt

from scipy import *

from pylab import *

import sys

import scipy.integrate as si

from scipy.integrate import quad

class Interval:

def __init__(self,a, b=None):

if b==None:

self.b=a

self.a=a

self.b=b

m=[self.a,self.b]

def sub(self,second):

c=self.second

d=self.second

m=[self.a-c,self.b-d]

#I1=Interval(1,4)

#I2=Interval(-2,-1)

#want I1-I2 to perform subtraction such that the return is [a-c,b-d]

def __repr__(self):

return'['+str(self.a)+','+str(self.b)+']'

def __str__(self):

return'['+str(self.a)+','+str(self.b)+']'

9 import numpy as np 10 import matplotlib.pyplot as plt 11 from scipy import * 12 from pylab import * 13 import sys 14 import scipy.integrate as si 15 from scipy.integrate import quad 16 17 class Interval: 18 19 def.-init-(self,a, b=None): 20 21 if bE None: self.b-a self.a self.b-b m= [self. a, sel f,b] =a 23 24 25 26 def sub(self,second): 27 28 29 30 31 32 c=self. Second d-self.second m-[self.a-c,self.b-d] #11Interval (1,4) #12-Interval (-2,-1) #want 11-12 to perform subtraction such that the return is [a-c , b-d] -repr-(self): return' ['+str(self.a)+, +str(self.b)+'1 def 34 35 36 37 38 39 def str-(self): return' ['+str(self.a)+, +str(self.b)+'1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions