ANMOL
2K18CSUN01054
BTECH CSE 4B
            MANAV RACHNA UNIVERSITY, FARIDABAD
             Department of Computer Science and Technology
Course: B.Tech
Subject: Programming for Problem Solving using Python(CSW208B)
                            Lab 9
Learning Outcome CO1: Student will be able to implement concepts of
OOPS.
1. Write a Python program that create a class tringle and define two
methods, create_triangle() and print_sides().
2. Write a Python program to create a class with two methods inputstr()
and printstr().
3. Write a Python program to create a class Rectangle that takes the
parameter length and width. The class should also contain a method for
computing its perimeter.
4.  Write a Python program to create a class Circle that takes the
parameter radius. The class should also contain two methods for
computing its area & perimeter respectively.
5. Write a Python program to demonstrate multiple Inheritance.
#1
class triangle:
     a=9
     b=8
     c=7
     st="Triangle created"
     def create_triangle(self):
       print(self.st)
     def print_side(self):
       print(self.a)
       print(self.b)
       print(self.c)
z=triangle()
z.print_side()
z.create_triangle()
#2
class IOString():
     def __init__(self):
       self.str1 = ""
     def input_String(self):
       self.str1 = input()
     def print_String(self):
       print(self.str1)
str1 = IOString()
str1.input_String()
str1.print_String()
#3
class rectangle():
     def __init__(self,breadth,length):
       self.breadth=breadth
       self.length=length
     def area(self):
       return self.breadth*self.length
a=int(input("Enter length of rectangle: "))
b=int(input("Enter breadth of rectangle: "))
obj=rectangle(a,b)
print("Area of rectangle:",obj.area())
#4
class Circle():
     def __init__(self, r):
       self.radius = r
     def area(self):
       return self.radius**2*3.14
     def perimeter(self):
       return 2*self.radius*3.14))
z = Circle(8)
print("Area of circle is : ",z.area())
print("Perimeter of circle is : ",z.perimeter())
#5
class Class1:
     def m(self):
       print("In Class1")
class Class2(Class1):
     def m(self):
       print("In Class2")
class Class3(Class1):
     def m(self):
        print("In Class3")
class Class4(Class2, Class3):
     def m(self):
       print("In Class4")
obj = Class4()
obj.m()
Class2.m(obj)
Class3.m(obj)
Class1.m(obj)