新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python程序:執(zhí)行算術運算
創(chuàng)新互聯(lián)python教程:

成都創(chuàng)新互聯(lián)"三網(wǎng)合一"的企業(yè)建站思路。企業(yè)可建設擁有電腦版、微信版、手機版的企業(yè)網(wǎng)站。實現(xiàn)跨屏營銷,產(chǎn)品發(fā)布一步更新,電腦網(wǎng)絡+移動網(wǎng)絡一網(wǎng)打盡,滿足企業(yè)的營銷需求!成都創(chuàng)新互聯(lián)具備承接各種類型的成都網(wǎng)站建設、網(wǎng)站建設項目的能力。經(jīng)過10年的努力的開拓,為不同行業(yè)的企事業(yè)單位提供了優(yōu)質(zhì)的服務,并獲得了客戶的一致好評。
寫一個 Python 程序,用一個實例對數(shù)值執(zhí)行算術運算。
執(zhí)行算術運算的 Python 程序
這個 python 程序允許用戶輸入兩個數(shù)據(jù)類型為 float 的數(shù)值。接下來,我們將使用這兩個值來執(zhí)行算術運算,如加法、減法、乘法、指數(shù)、模數(shù)和除法。
# Python Program to Perform Arithmetic Operations
num1 = float(input(" Please Enter the First Value Number 1: "))
num2 = float(input(" Please Enter the Second Value Number 2: "))
# Add Two Numbers
add = num1 + num2
# Subtracting num2 from num1
sub = num1 - num2
# Multiply num1 with num2
multi = num1 * num2
# Divide num1 by num2
div = num1 / num2
# Modulus of num1 and num2
mod = num1 % num2
# Exponent of num1 and num2
expo = num1 ** num2
print("The Sum of {0} and {1} = {2}".format(num1, num2, add))
print("The Subtraction of {0} from {1} = {2}".format(num2, num1, sub))
print("The Multiplication of {0} and {1} = {2}".format(num1, num2, multi))
print("The Division of {0} and {1} = {2}".format(num1, num2, div))
print("The Modulus of {0} and {1} = {2}".format(num1, num2, mod))
print("The Exponent Value of {0} and {1} = {2}".format(num1, num2, expo))對于這個 Python 程序進行算術運算的例子,我們將 num1 指定為 10,num2 為 3。請參考 python 程序頁面查看其余程序。
網(wǎng)站名稱:Python程序:執(zhí)行算術運算
文章路徑:http://www.fisionsoft.com.cn/article/codegis.html


咨詢
建站咨詢
