Homework Day04.2

Python作业 专栏收录该内容
7 篇文章 0 订阅

class Rectangle(object):
def __init__(self):
pass
def main(self):
width = float(input("长为："))
heightd = float(input("宽为："))
self.getArea(width,heightd)
self.getPerimeter(width,heightd)
def getArea(self,width,heightd):
Area = width * heightd
print('面积为：%.2f'%Area)
def getPerimeter(self,width,heightd):
Perimeter = (width + heightd) * 2
print('周长为：%.2f'%Perimeter)
if __name__ == '__main__':
rectangle = Rectangle()
rectangle.main()



class Fan(object):
def __init__(self):
pass
def main(self):
speed = int(input("1档,2档,3档"))
on = bool()
color1 = str('blue')
color2 = str('yellow')
if speed == 1:
print(on)
elif speed == 2:
elif speed == 3:
else:
pass
if __name__ == "__main__":
fan =Fan()
fan.main()


import math
class LinearEquation(object):
def __init__(self):
pass
def main(self):
n=float(input('输入边数:'))
side = int(input('输入边长:'))
self.isSolvable(n,side)
def isSolvable(self,n,side):
L = n*side
Area = float((n*side**2)/4*math.tan(math.pi/n))
print('周长为:',L,'面积为:%.2f'%Area)
if __name__ == "__main__":
linearequation = LinearEquation()
linearequation.main()


class LinearEquation(object):
def __init__(self):
pass
def main(self):
a = float(input('a= '))
b = float(input('b= '))
c = float(input('c= '))
d = float(input('d= '))
e = float(input('e= '))
f = float(input('f= '))
self.isSolvable(a,b,c,d,e,f)
def isSolvable(self,a,b,c,d,e,f):
if a*d-b*c ==0:
print('此方程无解')
else:
x = (e*d-b*f)/(a*d-b*c)
y = (a*f-e*c)/(a*d-b*c)
print('x为:',x)
print('y为:',y)
if __name__ == "__main__":
linearequation = LinearEquation()
linearequation.main()



class LinearEquation(object):
def __init__(self):
pass
def main(self):
x1,y1=eval(input('请输入第一条直线的第一个端点（逗号分隔）'))
x2,y2=eval(input('请输入第一条直线的第二个端点（逗号分隔）'))
x3,y3=eval(input('请输入第二条直线的第一个端点（逗号分隔）'))
x4,y4=eval(input('请输入第二条直线的第二个端点（逗号分隔）'))
self.math(x1,y1,x2,y2,x3,y3,x4,y4)

def math(self,x1,y1,x2,y2,x3,y3,x4,y4):
a = y2-y1
b = x2*y1-x1*y2
c = x2-x1
d = y4-y3
e = x4*y3-x3*y4
f = x4-x3
self.isSolvable(a,b,c,d,e,f)

def isSolvable(self,a,b,c,d,e,f):
y = float(a*e-b*d)/(a*f-c*d)
x = float(y*c-b)/a
print('交点的横纵坐标为：',(x,y))
if __name__ == "__main__":
linearequation = LinearEquation()
linearequation.main()


• 0
点赞
• 0
评论
• 0
收藏
• 一键三连
• 扫一扫，分享海报

07-22
03-24 26

12-14 29
12-15 66
12-29 19
04-27 21
01-23 849