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 trialSebastiaan van Vugt
Python Development Techdegree Graduate 13,554 PointsShould I provide the grade argument myself?
The grade argument has not been provided in this exercise and I'm unsure whether I should provide it. I have written the following in Idle but this isn't accepted:
class Student:
name = "Sebastiaan"
grade = 5
def praise(self):
print("You inspire me, {}".format(self.name))
def reassurance(self):
print("Chin up, {}. You'll get it next time!".format(self.name))
def feedback(self):
if self.grade > 50:
studS.praise()
elif self.grade < 50:
studS.reassurance()
studS = Student()
studS.feedback()
Thank you for any help!
1 Answer
Cooper Runstein
11,850 PointsYour function needs to be passed grade, feedback look closer to this:
def feedback(self, grade):
#Do stuff
Sebastiaan van Vugt
Python Development Techdegree Graduate 13,554 PointsSebastiaan van Vugt
Python Development Techdegree Graduate 13,554 PointsIf I just change this, my answer is still not accepted. Also, I really don't understand how I can pass a "grade" argument that has not been defined. Should I define it somewhere?
Reply after updated feedback: I can somehow not reply to your latest update but that really helped. Thank you. I was unsure where and how to put in the grade info. One more thing though, I noticed I get the same result when leaving out "return" in front of self.praise() and self.reassurance(). Am I correct in thinking that these two returns are superfluous?
Cooper Runstein
11,850 PointsCooper Runstein
11,850 PointsFrom a non coding perspective, you define what a student is with the class Student, then you create an instance called "studS", who has all the qualities of a student. If this student is then given a low grade, you can run the method feedback on the student to see the feedback. Hopefully this makes some sense, let me know if I can clarify anything.