python小作业

创建一个名叫 MyTriangle 的模块,它包含下面两个函数
#Returns true if the sum of any two sides isgreater than the third side.忙def isValid(sidel,side2,side3):
# Returns the area of the triangle.def area(sidel,side2,side3):
编写一个测试程序,读入三角形三边的值,若输人有效则计算面积。否则,显示输入无效计算三角形面积的公式在编程题2.14中给出。下面是一些示例运行。
Enter three sides in double:1.3.1.EmerInput is invalid
Enter three sides in double:l,1,1nterThe area of the triangle is 0.4330127018922193

源代码如下

(反向显示一个整数)编写下面的函数,反向显示一个整数
def reverse(number):
例如:reserse(3456)显示6543。编写一个测试程序,提示用户输入一个整数,然后显示它的反向数。

源代码如下:

def reverse(numder):
    swap = 0
    while numder != 0:
        num = numder % 10
        swap = swap * 10 + num
        numder //= 10
    return swap


a = int(input())
b = reverse(a)
print(b)

  • 10
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值