Question: a. Give two differences between object oriented programming and procedural programming, highlighting where each would be applied? b. Explain what is meant by Inheritance in
a. Give two differences between object oriented programming and procedural programming, highlighting where each would be applied?
b. Explain what is meant by Inheritance in OOP? Use an example in your explanation.
c. What is the meant by a constructor method in OOP? Give a short example
d. Describe the differences between local and global variables in python.
Question 2
a. In the code shown for class Circle: a. What type of variables are declared on lines 2 and 3? 1 mark
b. Write an appropriate constructor method for this class? 3 marks
b. Write a test class called TestCircle to complete the following:
a. Instantiate an object of type Circle, called c1, without passing a radius to it. 2 marks
b. Instantiate an object of type Circle, called c2, passing a radius of value 2.0 to it.2 marks
c. Output the following to the console: Circle c1 has radius of 1 and area of 3.14. 1 markCircle c2 has radius of 2.0 and area of 12.56. 1 mark
class circle: radius = 0.0 colour = “Red” def getArea(self): area = self.radius * self.radius * 3.14 return area def getPerimter(self): perimeter = 2 * 3.14 * self.perimeter return perimeter