[問題] 找直角三角形的值

作者: qnrother (雄商都敏俊)   2019-12-01 17:43:35
各位大大好!
有個關於Python的程式作業問題,問題如下:
Assume that there is a right triangle which has three integer sides and the th
ree sides of course satisfy the Pythagoras theorem.
Please use Python to write function(s) to find out all side-sets including sid
e1,side2,and the hypotenuse(use list or tuple or dict to store the data) and a
ll the sides are no larger than 500.
渣翻譯:用函數求直角三角形的邊(不大於500),邊的值需要符合畢氏定理(直角邊的
平方和需等於斜邊長的平方),存值的方式可以用list,tuple,dict。
求各位大大幫忙,非常感謝!
作者: yummy8765 (tsuyoku)   2019-12-01 17:56:00
提示:三層for loop 用畢氏定理當if的條件
作者: andy19960407 (258698)   2019-12-01 18:05:00
兩個for?
作者: nini200 (200妮妮)   2019-12-01 18:54:00
你應該先說自己卡在哪邊.....而不是要大家幫忙寫作業
作者: energyaxd (君)   2019-12-01 18:59:00
一開始就兩層loop if第三邊=整數 再慢慢刻 因為有些三角全等的關係其實一邊不用掃完1-500或是a固定時b超過多少c會大於500後面可以直接跳過這圈
作者: s860134 (s860134)   2019-12-01 22:02:00
for i in range(1,500):我已經幫你寫完一半了,剩下自己寫,不用謝我
作者: qnrother (雄商都敏俊)   2019-12-01 22:05:00
感謝各位大大,問題已經解決了!
作者: Kao0502 (鴻鴻)   2019-12-02 02:17:00
這不難吧,用for一下子就寫出來了

Links booklink

Contact Us: admin [ a t ] ucptt.com