#!/usr/bin/env python
#encoding=UTF-8

import math

#正方形的面积
def square_mianji(x):
return x*x

#立方体的表面积
def cube(x):
return xx6

#立方体的体积
def square_volume(x):
return pow(x,3)

#圆的面积
def circle®:
return math.pirr
#球的表面积
def ball_area®:
return 4rr*math.pi

#球的体积
def ball_volume®:
return (4math.pirrr)/3

if name"main":
a=input(“please input 1 to calculate square’s area,input 2 to calculate cube’s area and volume,input 3 to calculate circle’s area,input 4 to calculate ball’s area and volume:”)
a=int(a)
if a
1:
b=input(“please input the square’s length of side:”)
print(“the square’s area is {}”.format(square_mianji(int(b))))
elif a2:
b=input(“please input the cube’s length of side:”)
print(“the cube’s area is {},the volume is {}”.format(cube(int(b)),square_volume(int(b))))
elif a
3:
b=input(“please input the circle’s radius:”)
print(“the circle’s area is {}”.format(circle(int(b))))
elif a==4:
b=input(“please input the ball’s radius:”)
print(“the ball’s area is {},the volume is {}”.format(ball_area(int(b)),ball_volume(int(b))))
else:
print(“your input is wrong”)

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐