Python classes and instances call

self points to the object instance, as the first parameter, this parameter need not pass used.

class Student (Object):
     # define a Student class, 
    DEF  the __init__ (Self, name, Score, Age): 
        the self.name = name 
        self.score = Score 
        self.age = Age
     DEF print_score (Self):
         # define a class method, examples of callable objects 
        return the self.name, self.score
     DEF get_grade (Self):
         IF self.score> = 90 :
             return  ' A ' 
        elif self.score> = 60 :
             return  ' B ' 
        the else:
             Return  ' C ' 
    
ST1 = Student ( ' lingyummu ' , 67,25 )
     # Create a class object Student ST1 
Print (st1.name, st1.age, st1.score)
 Print (st1.print_score ())
 Print (ST1. get_grade ())

Reading and fitness there is always a way

Guess you like

Origin www.cnblogs.com/Renqy/p/11610956.html