新聞中心
創(chuàng)新互聯(lián)python教程:

成都創(chuàng)新互聯(lián)"三網(wǎng)合一"的企業(yè)建站思路。企業(yè)可建設(shè)擁有電腦版、微信版、手機(jī)版的企業(yè)網(wǎng)站。實(shí)現(xiàn)跨屏營(yíng)銷(xiāo),產(chǎn)品發(fā)布一步更新,電腦網(wǎng)絡(luò)+移動(dòng)網(wǎng)絡(luò)一網(wǎng)打盡,滿(mǎn)足企業(yè)的營(yíng)銷(xiāo)需求!成都創(chuàng)新互聯(lián)具備承接各種類(lèi)型的成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè)項(xiàng)目的能力。經(jīng)過(guò)10年的努力的開(kāi)拓,為不同行業(yè)的企事業(yè)單位提供了優(yōu)質(zhì)的服務(wù),并獲得了客戶(hù)的一致好評(píng)。
寫(xiě)一個(gè) Python 程序,用一個(gè)實(shí)例對(duì)數(shù)值執(zhí)行算術(shù)運(yùn)算。
執(zhí)行算術(shù)運(yùn)算的 Python 程序
這個(gè) python 程序允許用戶(hù)輸入兩個(gè)數(shù)據(jù)類(lèi)型為 float 的數(shù)值。接下來(lái),我們將使用這兩個(gè)值來(lái)執(zhí)行算術(shù)運(yùn)算,如加法、減法、乘法、指數(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))對(duì)于這個(gè) Python 程序進(jìn)行算術(shù)運(yùn)算的例子,我們將 num1 指定為 10,num2 為 3。請(qǐng)參考 python 程序頁(yè)面查看其余程序。
分享標(biāo)題:Python程序:執(zhí)行算術(shù)運(yùn)算
網(wǎng)站地址:http://www.5511xx.com/article/codegis.html


咨詢(xún)
建站咨詢(xún)
