猫史档案馆


【Python作品分享】新的作品【教程贴】

用户:惊雷这通天修为天塌地陷紫金锤惊雷这通天修为天塌地陷紫金锤查看:0 回复:0 评论:0 创建时间:2020-10-29T19:56:06


【作品展示】

center_image

 

【作品介绍】

4

 

【作品源代码】

import math


while True:
    c = input('计算方式:1+  2-  3x  4÷  5幂运算  6 绝对值  7in  8log10  9sin  10cos  11tan  12asin  13acos  14atan  15平方根  16阶乘')
    if (c == str('1') or c == str('2') or c == str('3') or c == str('4') or c == str('5')):
        a = input(' 第一个数字:')
        b = input(' 第二个数字:')
        d = float(a)
        e = float(b)
        if (c == str('1')):
            f = (d + e)
            print(f)
        elif (c == str('2')):
            f = (d - e)
            print(f)
        elif (c == str('3')):
            f = (d * e)
            print(f)
        elif (c == str('4')):
            f = (d / e)
            g = round(f, 2)
            print(g)
        else:
            f = (d ** e)
            print(f)
        i = input('是否继续运算?:1是   2否')
        j = int(i)
        if (j == 2):
            break
    else:
        a = input(' 数字:')
        d = float(a)
        if (c == str('6')):
            f = abs(d)
            print(f)
        elif (c == str('7')):
            f = math.log(d)
            print(f)
        elif (c == str('8')):
            f = math.log10(d)
            print(f)
        elif (c == str('9')):
            f = math.sin(math.radians(d))
            print(f)
        elif (c == str('10')):
            f = math.cos(math.radians(d))
            print(f)
        elif (c == str('11')):
            f = math.tan(math.radians(d))
            print(f)
        elif (c == str('12')):
            f = (math.asin(d))
            print(f)
        elif (c == str('13')):
            f = (math.acos(d))
            print(f)
        elif (c == str('14')):
            f = (math.atan(d))
            print(f)
        elif (c == str('15')):
            f = math.sqrt(d)
            print(f)
        else:
            f = (math.factorial(d))
            print(f)
        i = input('是否继续运算?:1是   2否')
        j = int(i)
        if (j == 2):
            break

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页