Question: Introduction to Object-oriented Analysis and Design 4. (10 points) Special methods and syntax sugar. Check whether or not a number is prime using the in

Introduction to Object-oriented Analysis and Design

 Introduction to Object-oriented Analysis and Design 4. (10 points) Special methods
and syntax sugar. Check whether or not a number is prime using

4. (10 points) Special methods and syntax sugar. Check whether or not a number is prime using the in operator. A prime number is a natural number greater than 1 and is divisible only by 1 and itself. (a) (2 points) Complete the definition of _contains_ in class PrimeNumber. Hint: Use the helper function isprime. (b) (2 points) Now, suppose you change the method name from _contains - to contains, as follows. Can you still make an object from class PrimeNumber? Answer Yes or No. (c) (2 points) After changing _contains _ to contains, what is the output of the following statement: print(issubclass (PrimeNumber, Container))? Answer True or False. (d) (2 points) Now, suppose class PrimeNumber inherits from the abstract base class Container, as follows. cIassPrimeNumber(Container)udefcontaine(ne1f=x)1pass Can you still make an object from class PrimeNumber? Answer Yes or No. What is the output of the following statement: print(issubclass (PrimeNumber, Container)) now? Answer True or False

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!