掃二維碼與項目經(jīng)理溝通
我們在微信上24小時期待你的聲音
解答本文疑問/技術咨詢/運營咨詢/技術建議/互聯(lián)網(wǎng)交流
創(chuàng)新互聯(lián)python教程:

寫一個 Python 程序,用算術運算符和函數(shù)計算一個數(shù)的立方,并舉例說明。
這個 Python 程序允許用戶輸入任何數(shù)值。接下來,Python 使用算術運算符找到該數(shù)字的立方體。
# Python Program to Calculate Cube of a Number
number = float(input(" Please Enter any numeric Value : "))
cube = number * number * number
print("The Cube of a Given Number {0} = {1}".format(number, cube))一個數(shù)字輸出的 Python 立方體
Please Enter any numeric Value : 5
The Cube of a Given Number 5.0 = 125.0這個 Python 立方數(shù)的例子同上,但是在這里,我們使用的是指數(shù)算子。
# Python Program to Calculate Cube of a Number
number = float(input(" Please Enter any numeric Value : "))
cube = number ** 3
print("The Cube of a Given Number {0} = {1}".format(number, cube)) Please Enter any numeric Value : 10
The Cube of a Given Number 10.0 = 1000.0在這個 Python 程序的立方體編號代碼片段中,我們定義了一個函數(shù),它可以找到給定數(shù)字的立方體。
# Python Program to Calculate Cube of a Number
def cube(num):
return num * num * num
number = float(input(" Please Enter any numeric Value : "))
cub = cube(number)
print("The Cube of a Given Number {0} = {1}".format(number, cub)) 
我們在微信上24小時期待你的聲音
解答本文疑問/技術咨詢/運營咨詢/技術建議/互聯(lián)網(wǎng)交流