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 — python_test/test16.py at master · Hanlen520/python_test

Expand file tree

/

test16.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
42 lines (34 loc) · 1013 Bytes
/

test16.py

Copy path

File metadata and controls

42 lines (34 loc) · 1013 Bytes
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
37
38
39
40
41
42
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
' 练习面向对象的类和实例 '
__author__ = 'sergiojune'
# 定义学生实例
class Student(object):
def __init__(self, name, score):
' 初始化实例,当创建实例时被调用这个函数,所以在实例化时需要传入这个函数的参数 '
self.name = name
self.score = score
def get_grade(self):
'对数据进行封装'
print('my name is %s' % self.name)
if self.score > 90:
print('your grade is A')
elif self.score > 75:
print('your grade is B')
else:
print('your grade is C')
# bart = Student()
# print(bart)
# # 给实例初始化名字属性和成绩
# bart.name = 'bart june'
# bart.score = 98
# print(Student)
# print(bart.name)
# print(bart.score)
# 实例化
tom = Student('Tom', 87)
print(tom.name)
print(tom.score)
bob = Student('Bob', 65)
# 调用实例方法
bob.get_grade()
You are visitor 01402520 — 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.