[英]I'm trying to make a bmi calculator in python and I don't know what I'm doing wrong
[英]I'm trying to write this code in python only using while loops, but I don't know what is wrong with it?
一個Python程序,它將在指定的時間間隔內輸出所有pythogorean三元組。 (a,b,c)由三個整數a <b <c組成,這樣兩個較小整數的平方和等於最大平方的平方。 程序應從用戶輸入一個整數值n> 10,並使用一系列嵌套的while循環,確定並打印出所有在閉合間隔[1,n](一個三分之一)中具有斜邊值(長度c)的畢達哥拉斯三分法每行)。
n=int(input("Enter on upper bound> 10:"))
c=1
a=1
b=1
if (a**2) + (b**2) == (c**2):
print ( a, b, c)
while (a**2) + (b**2) != (c**2) and c<n :
c=c+1
while (a**2) + (b**2) != (c**2) and b<c:
b=b+1
while (a**2) + (b**2) != (c**2) and a<b:
a=a+1
interval = [20, 50]
a = interval[0]
while a <= interval[1]:
b = interval[0]
while b <= interval[1]:
c = interval[0]
while c <= interval[1]:
if (a**2 + b**2) == c**2:
print(a, b, c)
c += 1
b += 1
a += 1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.