日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
Python程序:計(jì)算圓錐體積和表面積

創(chuàng)新互聯(lián)Python教程:

成都創(chuàng)新互聯(lián)公司,為您提供重慶網(wǎng)站建設(shè)、網(wǎng)站制作、網(wǎng)站營(yíng)銷推廣、網(wǎng)站開(kāi)發(fā)設(shè)計(jì),對(duì)服務(wù)成都服務(wù)器租用等多個(gè)行業(yè)擁有豐富的網(wǎng)站建設(shè)及推廣經(jīng)驗(yàn)。成都創(chuàng)新互聯(lián)公司網(wǎng)站建設(shè)公司成立于2013年,提供專業(yè)網(wǎng)站制作報(bào)價(jià)服務(wù),我們深知市場(chǎng)的競(jìng)爭(zhēng)激烈,認(rèn)真對(duì)待每位客戶,為客戶提供賞心悅目的作品。 與客戶共同發(fā)展進(jìn)步,是我們永遠(yuǎn)的責(zé)任!

如何用例子編寫(xiě) Python 程序求圓錐的體積和表面積?在我們進(jìn)入 Python 程序?qū)ふ覉A錐體的體積和表面積之前,讓我們看看定義和公式。

圓錐的 Python 表面積

如果我們知道圓錐的半徑和傾斜度,那么我們使用下面的公式計(jì)算圓錐的表面積: 表面積=圓錐的面積+圓的面積 表面積= πrl + πr 其中 r =半徑而 l =傾斜度(從圓錐頂部到圓錐邊緣的邊的長(zhǎng)度)

如果我們知道圓錐的半徑和高度,那么我們就可以用下面的公式計(jì)算圓錐的表面積: 表面積= πr +πr √h + r 我們也可以把它寫(xiě)成: 表面積= πr (r+√h + r)

因?yàn)榘霃?、高度和傾斜使形狀成為直角三角形。所以,利用勾股定理: l = h + r l = √h + r

圓錐的 Python 體積

圓錐體內(nèi)部的空間量稱為體積。如果我們知道圓錐體的半徑和高度,那么我們可以使用公式計(jì)算體積: 體積= 1/3 πr h(其中 h=圓錐體的高度)

圓錐的側(cè)面面積=πR1

尋找圓錐體積和表面積的 Python 程序

這個(gè) python 程序允許用戶輸入圓錐體的半徑和高度值。使用這些值,它將根據(jù)公式計(jì)算圓錐的表面積、體積、邊長(zhǎng)(傾斜)和側(cè)表面積。

# Python Program to find Volume and Surface Area of a Cone

import math

radius = float(input('Please Enter the Radius of a Cone: '))
height = float(input('Please Enter the Height of a Cone: '))

# Calculate Length of a Slide (Slant)
l = math.sqrt(radius * radius + height * height)

# Calculate the Surface Area
SA = math.pi * radius * (radius + l)

# Calculate the Volume
Volume = (1.0/3) * math.pi * radius * radius * height

# Calculate the Lateral Surface Area
LSA = math.pi * radius  * l

print("\n Length of a Side (Slant)of a Cone = %.2f" %l)
print(" The Surface Area of a Cone = %.2f " %SA)
print(" The Volume of a Cone = %.2f" %Volume);
print(" The Lateral Surface Area of a Cone = %.2f " %LSA)

在這個(gè)尋找圓錐體積和表面積的 Python 程序中,首先,我們使用下面的語(yǔ)句導(dǎo)入了數(shù)學(xué)庫(kù)。這將允許我們使用數(shù)學(xué)函數(shù),如 math.pi 和 math.sqrt。如果你沒(méi)有包括這一行,那么 math.pi 將通過(guò)一個(gè)錯(cuò)誤。

import math

在下方,Python 語(yǔ)句將要求用戶輸入半徑和高度值,并將用戶輸入值分配給相關(guān)變量。例如第一個(gè)值將分配給半徑,第二個(gè)值分配給高度

radius = float(input('Please Enter the Radius of a Cone: '))
height = float(input('Please Enter the Height of a Cone: '))

接下來(lái),我們將使用它們各自的公式計(jì)算圓錐體的體積、表面積、側(cè)面表面積和邊長(zhǎng)(斜面):

# Calculate Length of a Slide (Slant)
l = math.sqrt(radius * radius + height * height)
# Calculate the Surface Area
SA = math.pi * radius * (radius + l)
# Calculate the Volume
Volume = (1.0/3) * math.pi * radius * radius * height
# Calculate the Lateral Surface Area
LSA = math.pi * radius  * l

以下打印語(yǔ)句將幫助我們打印立方體的體積和表面積

print("\n Length of a Side (Slant)of a Cone = %.2f" %l)
print(" The Surface Area of a Cone = %.2f " %SA)
print(" The Volume of a Cone = %.2f" %Volume);
print(" The Lateral Surface Area of a Cone = %.2f " %LSA)

對(duì)于這個(gè)尋找圓錐體積和表面積的 Python 程序,我們已經(jīng)輸入了圓錐半徑= 5 和高度= 12

根據(jù)勾股定理,我們可以計(jì)算出斜面(邊長(zhǎng)): l = h+r l =√h+r l =√12+5 =>√144+25 l =√169 l = 13

圓錐體的表面積是 圓錐體的表面積= πr +πrl 圓錐體的表面積= πr (r + l) 它的意思是,圓錐體的表面積=數(shù)學(xué)π半徑(半徑+ l) 圓錐體的表面積= 3.14 5 (5+13)=>3.14 5 18 圓錐體的表面積= 282.6

圓錐的體積是 圓錐的體積= 1/3 πr h 它的意思是,圓錐的體積= (1.0/3) 數(shù)學(xué)π半徑半徑高度 圓錐的體積=(1.0/3) 3.14 5 5 12; 圓錐體的體積= 314

圓錐體的側(cè)表面面積為 側(cè)表面面積= πrl 這意味著,側(cè)表面面積=數(shù)學(xué)π半徑 l 側(cè)表面面積= 3.14 5 13 側(cè)表面面積= 204.1

讓我們使用半徑而不使用斜面(標(biāo)準(zhǔn)公式)來(lái)計(jì)算圓錐的半徑: 圓錐的表面積= πr +πr √h + r 圓錐的表面積= πr (r + √h + r )

意思是,表面積=數(shù)學(xué)π半徑(半徑+數(shù)學(xué) sqrt((高度高度)+(半徑半徑)) 圓錐體的表面積= 3.14 5 ( 5 + √12 + 5 ) 圓錐體的表面積= 3.14 5 (5+√169) =>3.14 5 (5+13) 圓錐體的表面積= 3.14 5 18 表面積

用函數(shù)求圓錐體積和表面積的 Python 程序

這個(gè) python 程序允許用戶輸入圓錐體的半徑和高度值。我們將半徑和高度值傳遞給函數(shù)參數(shù),然后它將根據(jù)公式計(jì)算圓錐體的表面積和體積。

# Python Program to find Volume and Surface Area of a Cone using functions

import math

def Vo_Sa_Cone(radius, height):
    # Calculate Length of a Slide (Slant)
    l = math.sqrt(radius * radius + height * height)

    # Calculate the Surface Area
    SA = math.pi * radius * (radius + l)

    # Calculate the Volume
    Volume = (1.0/3) * math.pi * radius * radius * height

    # Calculate the Lateral Surface Area
    LSA = math.pi * radius  * l

    print("\n Length of a Side (Slant)of a Cone = %.2f" %l)
    print(" The Surface Area of a Cone = %.2f " %SA)
    print(" The Volume of a Cone = %.2f" %Volume)
    print(" The Lateral Surface Area of a Cone = %.2f " %LSA)

Vo_Sa_Cone(6,10)

首先,我們使用 def 關(guān)鍵字定義了帶有兩個(gè)參數(shù)的函數(shù)。這意味著,用戶將輸入圓錐的半徑和高度。使用這些值,上面的函數(shù)將計(jì)算球體的表面積和體積,正如我們?cè)诘谝粋€(gè)示例 中所解釋的那樣

 Length of a Side (Slant)of a Cone = 11.66
 The Surface Area of a Cone = 332.92 
 The Volume of a Cone = 376.99
 The Lateral Surface Area of a Cone = 219.82 
>>> Vo_Sa_Cone(5,12)

 Length of a Side (Slant)of a Cone = 13.00
 The Surface Area of a Cone = 282.74 
 The Volume of a Cone = 314.16
 The Lateral Surface Area of a Cone = 204.20 
>>> 

注意:我們可以用中的參數(shù)調(diào)用函數(shù)。或者我們可以從 python shell 中調(diào)用它。請(qǐng)不要忘記函數(shù)參數(shù)


網(wǎng)站欄目:Python程序:計(jì)算圓錐體積和表面積
URL分享:http://www.5511xx.com/article/cdsojej.html