我是靠谱客的博主 潇洒小蝴蝶,最近开发中收集的这篇文章主要介绍python计算函数曲线与x轴包围的面积_python作业 函数计算图形面积之和,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

展开全部

#!62616964757a686964616fe58685e5aeb931333337386565/usr/bin/env python

# -*- coding: utf-8 -*-

from math import pi

import logging

class Geometrie(object):

"""docstring for Geometrie"""

def __init__(self):

pass

def say(self):

print self.__class__.__name__

def compute_area(self):

pass

def compute_circumference(self):

pass

def say_cirumfrerence(self):

print "%s 's cirumfrerence is: %f" % (self.__class__.__name__, self.compute_circumference())

def say_area(self):

print "%s 's cirumfrerence is: %f" % (self.__class__.__name__, self.compute_area())

class Ellipse(Geometrie):

"""docstring for Ellipse"""

def __init__(self,major_axis, minor_axis):

"""

major_axis is a

minor_axis is b

"""

super(Ellipse, self).__init__()

if not (isNum(major_axis) and isNum(minor_axis)):

raise Exception("TypeError: Please make sure the major:

{0!r} and minor {1!r} axis are correct.".format(major_axis, minor_axis))

else:

self.a=major_axis

self.b=minor_axis

def compute_circumference(self):

q=self.a+self.b

h=(abs((self.a-self.b)/(self.a-self.b)))**2

m=22/(7*pi)-1

n=(abs((self.a-self.b)/self.a))**(33.397)

return pi*q*(1+3*h/(10+(4-3*h)**(0.5)))*(1+m*n)

def compute_area(self):

return self.a*self.b*pi

class Square(Geometrie):

"""

docstring for Square"Geometrie

"""

def __init__(self, length, width):

super(Square,self).__init__()

if not (isNum(length) and isNum(width)):

raise Exception("TypeError: Please make sure the length:

{0!r} and width {1!r} axis are correct.".format(length, width))

else:

self.a = length

self.b = width

def compute_circumference(self):

return 2*(self.a+self.b)

def compute_area(self):

return self.a*self.b

class Circle(Geometrie):

"""docstring for Circle"""

def __init__(self, radius):

super(Circle, self).__init__()

if not (isNum(radius)):

raise Exception("TypeError: Please make sure the radius:

{0!r} is correct.".format(radius))

else:

self.r = radius

def compute_circumference(self):

return (2*self.r)*pi

def compute_area(self):

return pi*(self.r**2)

def isNum(value):

try:

value + 1

except TypeError:

return False

else:

return True

def main():

"""

docstring for main

"""

Es = Ellipse(2,1)

Es.say_cirumfrerence()

Es.say_area()

Sq = Square(2,1)

Sq.say_cirumfrerence()

Sq.say_area()

Cr = Circle(4)

Cr.say_cirumfrerence()

Cr.say_area()

if __name__ == '__main__':

main()

最后

以上就是潇洒小蝴蝶为你收集整理的python计算函数曲线与x轴包围的面积_python作业 函数计算图形面积之和的全部内容,希望文章能够帮你解决python计算函数曲线与x轴包围的面积_python作业 函数计算图形面积之和所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(40)

评论列表共有 0 条评论

立即
投稿
返回
顶部