GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — StarterLearningPython/python3code/chapter04/schoolwork.py at master · BKXGithub/StarterLearningPython

Expand file tree

/

schoolwork.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
36 lines (32 loc) · 1.05 KB
/

schoolwork.py

Copy path

File metadata and controls

36 lines (32 loc) · 1.05 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#coding:utf-8
'''
filename: schoolwork.py
'''
class Student:
def __init__(self, name, grade, subject):
self.name = name
self.grade = grade
self.subject = subject
def do_work(self, time):
if self.grade > 3 and time > 2:
return True
elif self.grade < 3 and time > 0.5:
return True
else:
return False
class Teacher:
def __init__(self, name, subject):
self.name = name
self.subject = subject
def evaluate(self, result=True):
if result:
return "You are great."
else:
return "You should work hard"
stu_zhang = Student('zhang', 5, 'math')
tea_wang = Teacher('wang', 'math')
teacher_said = tea_wang.evaluate(stu_zhang.do_work(1))
print("Teacher {0} said: {1}, {2}".format(tea_wang.name, stu_zhang.name, teacher_said))
stu_newton = Student('Newton', 6, 'physics')
teacher_newton = tea_wang.evaluate(stu_newton.do_work(4))
print("Teacher {0} said: {1}, {2}".format(tea_wang.name, stu_newton.name, teacher_newton))
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.