Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

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... 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

Accounting Information Systems

Authors: George H. Bodnar, William S. Hopwood

11th Edition

0132871939, 978-0132871938

More Books

Students also viewed these Programming questions

Question

How will you sort 1 PB numbers? 1 PB = 1000 TB.

Answered: 1 week ago