日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

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

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python程序:計(jì)算長度和寬度查找矩形面積

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

創(chuàng)新互聯(lián)公司是一家專業(yè)提供平房企業(yè)網(wǎng)站建設(shè),專注與做網(wǎng)站、成都網(wǎng)站制作、成都h5網(wǎng)站建設(shè)、小程序制作等業(yè)務(wù)。10年已為平房眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站設(shè)計(jì)公司優(yōu)惠進(jìn)行中。

用一個實(shí)際例子編寫 Python 程序,利用長度和寬度找到矩形的面積。

使用長度和寬度查找矩形面積的 Python 程序示例 1

這個 Python 程序允許用戶輸入矩形的長度和寬度。使用這兩個值,它可以找到矩形的面積。如果我們知道矩形的長度和寬度。計(jì)算矩形面積的數(shù)學(xué)公式是:面積=長度*寬度。

# Python Program to find Area of a Rectangle using length and width

length = float(input('Please Enter the Length of a Triangle: '))
width = float(input('Please Enter the Width of a Triangle: '))

# calculate the area
area = length * width

print("The Area of a Rectangle using", length, "and", width, " = ", area)

使用長度和寬度計(jì)算矩形面積的 Python 程序示例 2

這個 Python 代碼查找矩形的面積同上。然而,我們使用函數(shù)的概念分離了 python 程序的邏輯。

# Python Program to find Area of a Rectangle using length and width

def area_of_Rectangle(length, width):
    return length * width
length = float(input('Please Enter the Length of a Triangle: '))
width = float(input('Please Enter the Width of a Triangle: '))

# calculate the area of a Rectangle
area = area_of_Rectangle(length, width)

print("The Area of a Rectangle using", length, "and", width, " = ", area)
Please Enter the Length of a Triangle: 125
Please Enter the Width of a Triangle: 65
The Area of a Rectangle using 125.0 and 65.0  =  8125.0

分享題目:Python程序:計(jì)算長度和寬度查找矩形面積
當(dāng)前URL:http://www.dlmjj.cn/article/cdoccpg.html