Home > other >  How Python packaging function, provides a class would be even better.
How Python packaging function, provides a class would be even better.

Time:09-25

How Python packaging function, provides a class would be even better,

CodePudding user response:

The class Student (object) :
The constructor of the # is similar to other high-level languages
Def __init__ (self, name, score) :
The self. The name=name
The self. The score=score

Def print_score (self) :
Print (" % s: % s "% (self. The name, the self. Score))

Def get_grade (self) :
If the self. The score & gt;=90:
Return the 'A'
If the self. The score & gt;=60:
Return 'B'
Return the 'C'
Bart=Student (" frank ", 100)
Print (bart. Get_grade ())

CodePudding user response:

You can learn to the novice tutorial,

CodePudding user response:

Def encapsulation, return the return value
  • Related