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

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

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python程序:檢查三角形是否有效

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

為略陽等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及略陽網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為做網(wǎng)站、網(wǎng)站設(shè)計(jì)、略陽網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!

編寫一個(gè) Python 程序,使用用戶指定的角度檢查三角形是否有效。記住,任何三角形都是有效的,如果三角形中 3 個(gè)角的和等于 180°

檢查三角形是否有效的 Python 程序示例 1

這個(gè) python 程序幫助用戶輸入三角形的所有角度。接下來,我們使用 If Else 語句檢查給定角度之和是否等于 180°。如果為真,print 語句將打印一個(gè)有效的三角形。否則, python 程序打印為無效三角形。

# Python Program to check Triangle is Valid or Not

a = int(input('Please Enter the First Angle of a Triangle: '))
b = int(input('Please Enter the Second Angle of a Triangle: '))
c = int(input('Please Enter the Third Angle of a Triangle: '))

# checking Triangle is Valid or Not
total = a + b + c

if total == 180:
    print("\nThis is a Valid Triangle")
else:
    print("\nThis is an Invalid Triangle")

驗(yàn)證三角形是否有效的 Python 程序示例 2

在上面的 Python 例子中,我們忘了檢查任何一個(gè)角度是否為零。因此,我們使用邏輯與運(yùn)算符來確保所有角度都大于 0

a = int(input('Please Enter the First Angle of a Triangle: '))
b = int(input('Please Enter the Second Angle of a Triangle: '))
c = int(input('Please Enter the Third Angle of a Triangle: '))

# checking Triangle is Valid or Not
total = a + b + c

if (total == 180 and a != 0 and b != 0 and c != 0):
    print("\nThis is a Valid Triangle")
else:
    print("\nThis is an Invalid Triangle")
Please Enter the First Angle of a Triangle: 70
Please Enter the Second Angle of a Triangle: 70
Please Enter the Third Angle of a Triangle: 40

This is a Valid Triangle
>>> 
=================== RESTART: /Users/suresh/Desktop/simple.py ===================
Please Enter the First Angle of a Triangle: 90
Please Enter the Second Angle of a Triangle: 90
Please Enter the Third Angle of a Triangle: 0

This is an Invalid Triangle
>>>

新聞名稱:Python程序:檢查三角形是否有效
轉(zhuǎn)載源于:http://m.5511xx.com/article/cceoipo.html