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
Related Q & A:
- How do I make a python web program that is on a ubuntu server allow access to the server?Best solution by Yahoo! Answers
- How can I get a computer programming job?Best solution by Stack Overflow
- How do I get a job in IT or Software Development if I have no experience and only a 3rd class degree?Best solution by answers.yahoo.com
- How do I get a job in game testing?Best solution by Yahoo! Answers
- Where can I find a computer programming internship?Best solution by ChaCha
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.