Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

I got a problem with my script, Help!

Alright so me and my friend were doing some programming "jokes" and we fell on something really stupid, anyways I ended up telling him that I will make a girl evaluation script and so I did... as you see the language is very .. hmm how can I say it .. inappropriate ? yup that's the word, anyways It is working but the thing is that after some prints it just prints None too... why ? I had a hard time with classes, if I don't create the approval function and just lay that code outside the approval function everything goes nuts any insights in that ?

Sorry for the nastiness..

Regards Penguin!

class Girl_Assets: # I work for you vadimmm !! told ya I would do it !!

    def __init__(self, ass, tits, score = 0):

        self.ass = ass
        self.tits = tits
        self.score = score

    def ass_eval(self):

        if self.ass >= 5:
            print("\n Booty: Daym girl, shake it ! ")
            self.score += 4

        else:
            print("\n Booty: Please do some squats ! ")
            self.score -= 2

    def tits_eval(self):

        if self.tits >= 5:
            print("\n Titties: Baby Girl.. I need some milk ! ")
            self.score += 4

        else:
            print("\n Titties: Some are blessed and some are not.. ")
            self.score -= 2


class Printer(Girl_Assets):
    def __init__(self, ass, tits, score):
        super().__init__(ass, tits, score)

    def approval(self):
        if self.score >= 5:
            print(" Conclusion: I approve!")

        else:
            print(" Conclusion: Beauty is something debatable..")

girl_1 = Printer(int(input(' Type a number from 0 to 10 for the booty > ')), int(input(' Type a number from 0 to 10 for the tities > ')), 0)     

print(girl_1.ass_eval())
print(girl_1.tits_eval())
print(girl_1.approval())

3 Answers

First of all, I think if you take the OOP python class, you're going to be golden. Second of all, yo what????? how did your convo go to betting that you'll make this program lmao. Anyways, I'm answering from my phone, my laptop is not with me, I'll be sure to check your code by tomorrow.

I don't really understand what golden means, but It sounds good... thanks, it was a very very long conversation anyways I waiting for your reply, something else I wanted to ask is in the variable girl_1 which is the instance of the object Printer which inherits from girl assets you can see that I add two inputs in as parameters, how could I rewrite this more cleanly and where could I get a deeper understanding of classes ? are we going to take this further in this course or should I find something of my own, any recommendations would be great. Lastly when I finish this course what can I do to enhance my python skills or any kind of coding skill ? should I buy a book ? I know that I need to be doing mini projects but I don't know I feel like something essential is missing..

I see what you mean by "everything gets funny when I lay my code", I'd say if you make a clean screen function and run it first. I think that the 'None' is coming from setting 'self.somthing' to a number. I think it would be easier if you set the score and everything and do an if statement for the score.

I figured it out jonlunsford was right, it was the fact that I was calling my instances from within a print(), I saw someone using it so I couldn't expect that it was that one.. Anyways thank you very much for your time!

Regards Penguin

jonlunsford
jonlunsford
16,746 Points

Cyber:

There is nothing wrong with your Classes. The problem is how you are referencing the methods 'a*s_eval()' and 't**s_eval()'. These methods don't return anything, so when you call them in the print statement 'None' get's printed. Here is how you would access those methods, by eliminating the print statement in the last three lines of your code. Those methods are printing something anyway, so you don't need to call them within a print.

girl1.a**_eval()
girl1.t**s_eval()
girl1.approval()

Thank you very much jonlunsford

something else I wanted to ask is in the variable girl_1 which is the instance of the object Printer which inherits from girl assets you can see that I add two inputs in as parameters, how could I rewrite this more cleanly and where could I get a deeper understanding of classes ? are we going to take this further in this course or should I find something of my own, any recommendations would be great. Lastly when I finish this course what can I do to enhance my python skills or any kind of coding skill ? should I buy a book ? I know that I need to be doing mini projects but I don't know I feel like something essential is missing.. and what about the fact that if i take the code block within the approval function nothing works ? why does this happen ?

Anyways thanks allot for the effort to reply and read my problem..

jonlunsford
jonlunsford
16,746 Points

Cyber:

To answer your first question, I don't see the apparent need for a Printer class. You only have one function in it --approval(). If it were me, I would get rid of the Printer class and put the approval() function into the Girl_Assets class. Then you just need to create an instance of Girl_Assets each time. For example:

girl_1 = Girl_Assets(5, 5, 0)
girl_1.a_eval()
girl_1.t_eval()
girl_1.approval()

To answer your other questions. I'm sure the Treehouse videos will give you a good introduction to classes. For additional help, you could consult a book such as "Python 3 Object-oriented Programming, 2nd ed." by Dusty Phillips. I'm sure there are no shortage of books that can help you with Python Classes and Objects.

I totally agree with you but I wanted to try inheritnace so I made it that way, the problem is why everything gets funny when i lay my code outsode the function ?

Thanks again!