Is abstract class field in python possible?

I have a python programming question about testing an _init_ class?

  • this is what my professor has given me Please make sure you go through each item on the checklist above before turing in your assigment. Missing items reduces your grade.  ___1. Type in and test the Square with __init__ class from the slides ___2. Create similar class for a rectangle... name should be... you guessed it... Rectangle ___3. Attributes: x, y, width and height (must be passed into __init__), all with default values of 1 ___4. Methods: area and perimeter (not that these will use the width and height attributes) ___5. Instantiate both classes. ___6. Print the areas and perimeters of Square and a Rectangle calculated using the class methods ___7.Document your code: Every meaningful line should have documentation describing what it does. Due Date March 12, 2012 11:59:00 PM EDT this is what i have class Square: s=1 x=1 y=1 def _init_(self, x=1,y=1): self.s = x self.s = y self.s = r def area(self): return self.s*self.s def perimeter(self): return self.s*4 s = Square() s.r= 3 s.area() class Rectangle: w = 1 h = 1 r = 1 def _init_(self,w=1,h=1): self.w = w self.h = h def area(self): return self.w*self.h def perimeter(self): return self.w*2 + self.h*2 it runs with no errors.. but nothing prints out ... help appreciated

  • Answer:

    I think its because you do not have print statement. To print the area of square for example you should have a statement like: print s.area() This will help you to print the value that the area function is returning. You can use print for other functions as well.

Venice at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.