Discuss / Python / 再简单的代码也要亲手敲一遍

再简单的代码也要亲手敲一遍

Topic source

翁岚敏

#1 Created at ... [Delete] [Delete and Lock User]

PI = 3.14 def S(r): return PIr*2

r1=12.34 r2=9.08 r3=73.1

print('S1 =',S(r1)) print('S2 =',S(r2)) print('S3 =',S(r3))

G-Master-G

#2 Created at ... [Delete] [Delete and Lock User]

但是你这敲错了 **

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

PI = 3.14
def S(r):
    return PI*(r**2)

r=float(input('请输入半径:'))

print('面积为:%.2f'%S(r))

  • 1

Reply