猫史档案馆


【Python作品分享】一个聪明的输入程序【作品秀】

用户:Ving蔚影工作室Ving蔚影工作室查看:0 回复:1 评论:0 创建时间:2021-12-21T21:42:40


【作品展示】

center_image

 

【作品介绍】

永远告别print()和input()的简单,用一个简单的函数就能搞定运算,数据转换,快来试一试吧!

 

【作品源代码】

def cout(anythingelse, and_):

    try:
        anythingelse = int(anythingelse)
        and_ = int(and_)
        c = input('Choose-plus or minus or times or divide, write A,B,C or D')
        if c == 'A':
            print((anythingelse + and_))
        elif c == 'B':
            print((anythingelse - and_))
        elif c == 'C':
            print((anythingelse * and_))
        elif c == 'D':
            print((anythingelse / and_))
        else:
            print('blablabla')
    except TypeError:
        print(anythingelse, and_)
    finally:
        print('Bye-------------------------')
    return anythingelse

h = input('Any things else?')
k = input('And?')

cout(h, k)

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
编码已破译编码已破译

eval不香吗

点赞0


评论