新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python程序:兩個數(shù)相減
創(chuàng)新互聯(lián)python教程:

創(chuàng)新互聯(lián)專注于昆山企業(yè)網(wǎng)站建設(shè),成都響應(yīng)式網(wǎng)站建設(shè)公司,成都做商城網(wǎng)站。昆山網(wǎng)站建設(shè)公司,為昆山等地區(qū)提供建站服務(wù)。全流程按需設(shè)計網(wǎng)站,專業(yè)設(shè)計,全程項目跟蹤,創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)
寫一個 Python 程序來減去兩個數(shù)字。
num1 = 128
num2 = 256
sub = num1 - num2
print('The Result of subtracting {0} from {1} = {2}'.format(num2,num1,sub))The Result of subtracting 256 from 128 = -128這個 Python 程序接受兩個整數(shù)值,并從另一個數(shù)中減去一個數(shù)。
num1 = int(input("Please Enter the First Number = "))
num2 = int(input("Please Enter the second number = "))
sub = num1 - num2
print('The Result of subtracting {0} from {1} = {2}'.format(num2,num1,sub))其他產(chǎn)出很少
Please Enter the First Number = 11
Please Enter the second number = 43
The Result of subtracting 43 from 11 = -32
Please Enter the First Number = 99
Please Enter the second number = 23
The Result of subtracting 23 from 99 = 76Python 編程使用函數(shù)減去兩個數(shù)。
def subtractTwoNum(a, b):
return a - b
num1 = int(input("Please Enter the First Number = "))
num2 = int(input("Please Enter the second number = "))
sub = subtractTwoNum(num1, num2)
print('The Result of subtracting {0} from {1} = {2}'.format(num2,num1,sub))Please Enter the First Number = 12
Please Enter the second number = 49
The Result of subtracting 49 from 12 = -37
Please Enter the First Number = 70
Please Enter the second number = 37
The Result of subtracting 37 from 70 = 33 文章題目:Python程序:兩個數(shù)相減
文章地址:http://fisionsoft.com.cn/article/djpdihj.html


咨詢
建站咨詢
