当前位置:网站首页>Design a circle class with private member radius representing radius and function get_ Radius () is used to obtain the radius and area () is used to calculate the area of the circle; (2) Define a tabl
Design a circle class with private member radius representing radius and function get_ Radius () is used to obtain the radius and area () is used to calculate the area of the circle; (2) Define a tabl
2022-04-22 07:19:00 【Gratifying clover (●  ̄ (エ)  ̄ ●)】
1、(1) Design a circle class (circle), There are private members radius For radius , function get_radius( ) Used to obtain the radius 、area( ) Used to calculate the area of a circle ; (2) Define a table class table, Private data inside height Stands for height , function get_height( ) Used to obtain height ; (3) Define a round table class round_table, It is a subclass of the first two classes , Add member functions show( ) Used to output round table radius 、 Desktop area 、 Height, etc . (4) Test round table class round_table.
class Shape():
def zhouchang(self):
pass
def mianji(self):
pass
class Circle(Shape):
PI = 3.14
def __init__(self, radius):
self.radius = radius
def zhouchang(self):
return 2 * self.PI * self.radius
def mianji(self):
return self.PI * self.radius ** 2
class Rectangle(Shape):
def __init__(self, c, k):
self.c = c
self.k = k
def zhouchang(self):
return 2 * (self.c + self.k)
def mianji(self):
return self.c * self.k
def ShapeCalculate(a):
s = a.mianji()
z = a.zhouchang()
print(' The circumference is {}, The area is {}'.format(s, z))
aa = Circle(4)
bb = Rectangle(3, 4)
ShapeCalculate(aa)
ShapeCalculate(bb)

版权声明
本文为[Gratifying clover (●  ̄ (エ)  ̄ ●)]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220609573031.html
边栏推荐
- ASP. Net daily development notes ----- JS script executed in the background
- 日常开发随手记------VS上一些好用的设置
- ROS安装及基础与入门
- Quotient principle of modular division
- Nacos cluster configuration
- Service configuration center of Nacos
- Is digital IC design promising? How about career development and salary?
- C语言 | 快速排序
- Jeecg project deployment notes
- paging
猜你喜欢

Installer et modifier les chemins d'installation des plug - ins utools et vscode

Format control of format() method

桥接模式下主机ping不通虚拟机

a5 transceiver 信号vod和预加重调整关系
![[bug notes] antd table height adaptive window height](/img/44/b6d2dc589520767fe6f7d0e428f684.png)
[bug notes] antd table height adaptive window height

Service configuration center of Nacos

Introduction to IC Analog Layout - learning notes on layout Basics (3)

【Bug小记】antd表格高度自适应窗口高度
![[SVN] subversion installation notes](/img/71/d07dbe13d1ef160b4e14439e7645ef.png)
[SVN] subversion installation notes

14行代码完成任意选择图片爬取
随机推荐
Beyond Compare“授权密钥已被吊销”的解决办法
Pixhawk4+Up Board / NUC Implement VIO By Deploying T265
[bug notes] antd table height adaptive window height
【Bug小记】antd表格高度自适应窗口高度
作用域与生存期(翁恺老师)
Raspberry Pi 4b
定义类Shape作为父类,并在类中定义方法求周长和面积; (2)定义Shape子类圆形(circle),具有半径属性和常量PI,同时重写父类中的方法; (3)定义Shape子类长方形(rect
微信浏览器无法长期保存cookie
Robomaster大疆飞手考核
Install and modify the installation path of utools and vscode plug-ins
[jeecg] modify VISER chart color style
Distributed task scheduling and computing framework: powerjob advanced features - container 03
桥接模式下主机ping不通虚拟机
浙大版《C语言程序设计(第3版)》题目集 练习7-4 找出不是两个数组共有的元素
Process of stepping on the pit in the flutter environment
ASP. Net daily development notes ---- export to excel
用大写的字段接受最终首字母却变小写
format()方法的格式控制
Practice of using generics and reflection (including a generic cache) -- handwritten ORM ORM framework
paging