Python程序:两个数相乘

创新互联Python教程:

站在用户的角度思考问题,与客户深入沟通,找到龙山网站设计与龙山网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:网站设计制作、网站设计、企业官网、英文网站、手机端网站、网站推广、域名注册、虚拟空间、企业邮箱。业务覆盖龙山地区。

写一个 Python 程序将两个数字相乘。这个 Python 示例接受两个整数值,并计算这两个数字的乘积。

num1 = int(input("Please Enter the First Number to Multiply  = "))
num2 = int(input("Please Enter the second Number to Multiply = "))

mul = num1 * num2
print('The Result of Multipling {0} and {1} = {2}'.format(num1, num2, mul))

两个浮点数相乘的 Python 程序。

num1 = float(input("Please Enter the First Number to Multiply  = "))
num2 = float(input("Please Enter the second Number to Multiply = "))

mul = num1 * num2
print('The Result of Multipling {0} and {1} = {2}'.format(num1, num2, mul))
Please Enter the First Number to Multiply  = 17.89
Please Enter the second Number to Multiply = 28.56
The Result of Multipling 17.89 and 28.56 = 510.9384

Python 程序使用函数将两个数字相乘

def multiplyTwoNum(a, b):
    return a * b

num1 = int(input("Please Enter the First Number to Multiply  = "))
num2 = int(input("Please Enter the second Number to Multiply = "))

mul = multiplyTwoNum(num1, num2)
print('The Result of Multipling {0} and {1} = {2}'.format(num1, num2, mul))
Please Enter the First Number to Multiply  = 12
Please Enter the second Number to Multiply = 19
The Result of Multipling 12 and 19 = 228

本文题目:Python程序:两个数相乘
转载来于:http://bzwzjz.com/article/djcgdos.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都网站建设 成都网站制作 外贸网站设计方案 网站制作 成都网站建设流程 营销型网站建设 成都网站制作 响应式网站设计方案 网站制作公司 成都网站制作 LED网站设计方案 成都网站设计 定制网站设计 成都网站制作 成都网站制作 成都网站建设 古蔺网站建设 手机网站制作 企业网站建设公司 成都网站设计公司 高端网站建设 企业网站设计