Define A Class Named Rectang Le Which Represents Rectangles [Solved]

Question 1


Question 2

Where was Ludwig Wittgenstein born? Ludwig Wittgenstein Ludwig Wittgenstein is considered to be one of the greatest philosophers of the 20th century. His work and ideas included subjects like linguistics, mathematics, logic, and the philosophy of the mind. His m
Question 3

How did Ludwig Wittgenstein die? Ludwig Wittgenstein Ludwig Josef Johann Wittgenstein held many positions during his lifetime such as elementary school teacher, university professor, soldier during World War I, author, and hospital porter during World War II. Born in Austria in 1889, his reputation has grown exponentially where today he is regarded as one of the most important philosophers of the 20th century.
Question 4

What does John Rawls mean by saying “justice as fairness”? John Rawls: John Rawls (John Bordley Rawls) was an important and influential American philosopher during the twentieth century. He was born on February 21, 1921 and died on November 24, 2002. He is best known for his philosophical work A Theory of Justice (1971).
Answer to question 1

Code: TASK 1 andTASK 2

class Rectangle():
    
    #TASK 1
    def __init__(self, width=1, height=1):
        self.height = height
        self.width = width
    
    def __str__(self):
        return f’Rectangle:{self.width}x{self.height}’

    #TASK2
    def get_area(self):
        return self.height*self.width
    
    def get_perimeter(self):
        return 2*(self.height+self.width)
    

#Task 1
r1 = Rectangle(3,4)
print(r1.width,r1.height)
print(r1)

r2 = Rectangle()
print(r2.width,r2.height)
print(r2)

#task2
print(r1.get_area())
print(r1.get_perimeter())
print(r2.get_area())
print(r2.get_perimeter())

Code screenshot:

output attached:

TASK3 : to create class RectangleBound

class Rectangle:
    
    #TASK 1
    def __init__(self, width=1, height=1):
        self.height = height
        self.width = width
    
    def __str__(self):
        return f’Rectangle:{self.width}x{self.height}’

    #TASK2
    def get_area(self):
        return self.height*self.width
    
    def get_perimeter(self):
        return 2*(self.height+self.width)


class RectangleBound:
    def __init__(self, width=100, height=100):
        self.height = height
        self.width = width
        self.rectangles=[]
    

#task3
bound1 = RectangleBound()
print(bound1.width,bound1.height,bound1.rectangles)
bound2 = RectangleBound(10,20)
print(bound2.width,bound2.height)
bound3 = RectangleBound(20,10)
print(bound3.width,bound3.height)

TASK 4: 

class Rectangle:
    
    #TASK 1
    def __init__(self, width=1, height=1):
        self.height = height
        self.width = width
    
    def __str__(self):
        return f’Rectangle:{self.width}x{self.height}’

    #TASK2
    def get_area(self):
        return self.height*self.width
    
    def get_perimeter(self):
        return 2*(self.height+self.width)


class RectangleBound:
    def __init__(self, width=100, height=100):
        self.height = height
        self.width = width
        self.rectangles=[]
    
    def add_rectangle(self,rectangle):
        if(rectangle.width<self.width and rectangle.height<self.height):
            self.rectangles.append(rectangle)
    
    
    def __str__(self):
        if(len(self.rectangles)>0):
            str =  “Rectangles:\n” ;
            for x in self.rectangles:
                str+= f’Rectangle:{x.width}x{x.height}\n’
            return str
        else:
            return “No rectangles.”
        
# task 4
bound1 = RectangleBound(200,200)
print(bound1)
bound1.add_rectangle(Rectangle(20,40))
bound1.add_rectangle(Rectangle(40,60))
bound1.add_rectangle(Rectangle(200,150))

print(bound1)

Code screenshot :

#task 5:

Code :

class Rectangle:
    
    #TASK 1
    def __init__(self, width=1, height=1):
        self.height = height
        self.width = width
    
    def __str__(self):
        return f’Rectangle:{self.width}x{self.height}’

    #TASK2
    def get_area(self):
        return self.height*self.width
    
    def get_perimeter(self):
        return 2*(self.height+self.width)


class RectangleBound:
    def __init__(self, width=100, height=100):
        self.height = height
        self.width = width
        self.rectangles=[]
    
    def add_rectangle(self,rectangle):
        if(rectangle.width<self.width and rectangle.height<self.height):
            self.rectangles.append(rectangle)
    
    
    def __str__(self):
        if(len(self.rectangles)>0):
            str =  “Rectangles:\n” ;
            for x in self.rectangles:
                str+= f’Rectangle:{x.width}x{x.height}\n’
            return str
        else:
            return “No rectangles.”
    
    
    def get_number_of_rectangles(self):
        return len(self.rectangles)
    
    
    def get_total_area(self):
        total =0
        for x in self.rectangles:
            total += x.get_area()
        return total
        
# task 4
bound1 = RectangleBound(200,200)
print(bound1)
bound1.add_rectangle(Rectangle(20,40))
bound1.add_rectangle(Rectangle(40,60))
bound1.add_rectangle(Rectangle(400,300))

print(bound1.get_number_of_rectangles())
print(bound1.get_total_area())

Code screenshot :


Answer to question 2

Answer and Explanation: Ludwig Wittgenstein was born on April 26, 1889. He was born in Vienna, Austria-Hungary. At this point, Austria was not its own nation yet, and would not be until the conclusion of World War I.
Answer to question 3

Answer and Explanation: Ludwig Wittgenstein passed away on April 29, 1951 while he was living in Cambridge, England. The official cause of death was natural causes, but his extremely intense nature probably hastened his demise.
Answer to question 4

Answer and Explanation: John Rawls’ phrase “justice as fairness” refers to his social justice belief that societal structures and systems should be designed to benefit the most disadvantaged people within a society and provide equal basic liberties and equal opportunity to everyone.

Leave a Comment