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


Step by Step Solution

3.47 Rating (163 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The detailed answer for the above question is provided below a Differences between ObjectOriented Programming OOP and Procedural Programming Data and Behavior OOP In OOP data and behavior are encapsul... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!