Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fe13d54 commit dbea25aCopy full SHA for dbea25a
py3/oop_basic/student.py
@@ -0,0 +1,29 @@
1
+#!/usr/bin/env python3
2
+# -*- coding: utf-8 -*-
3
+
4
+class Student(object):
5
6
+ def __init__(self, name, score):
7
+ self.name = name
8
+ self.score = score
9
10
+ def print_score(self):
11
+ print('%s: %s' % (self.name, self.score))
12
13
+ def get_grade(self):
14
+ if self.score >= 90:
15
+ return 'A'
16
+ elif self.score >= 60:
17
+ return 'B'
18
+ else:
19
+ return 'C'
20
21
+bart = Student('Bart Simpson', 59)
22
+lisa = Student('Lisa Simpson', 87)
23
24
+print('bart.name =', bart.name)
25
+print('bart.score =', bart.score)
26
+bart.print_score()
27
28
+print('grade of Bart:', bart.get_grade())
29
+print('grade of Lisa:', lisa.get_grade())
0 commit comments