这仅仅是一个作业
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()
radius1 = float(5)
radius2 = float(10)
color1 = str('blue')
color2 = str('yellow')
self.gongneng(speed,on,radius1,radius2,color1,color2)
def gongneng (self,speed,on,radius1,radius2,color1,color2):
if speed == 1:
print(on)
elif speed == 2:
print('半径为:',radius1,'颜色:',color1)
elif speed == 3:
print('半径为:',radius2,'颜色:',color2)
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()
今天的作业就写完了接下来又到了每日更新头像的环节
现在是凌晨 1.25 Joker 你等着啊!