Python 实战案例一:交互式求圆面积
# -*- coding:utf-8 -*- import math '''案例一:交互式求圆面积''' while True: # 用户输入 r = input("请输入圆的半径:") if not r.isalpha(): # 数据类型转化 r = float(r) # 计算面积 ciclesArea = math.pi*r**r # 输出 print("圆面积是:" + str(ciclesArea)) print("\n\t1:继续;2:退出\n")
s = input("请选择:")
if int(s) == 1: continue elif int(s) == 2: break else: print("你输入的数据类型异常,请重新输入") continue