Write a code or draw a flowchart to find all Pythagorean Triples (a,b,c) where a
The print built-in function displays the specified string to the output.
X
Game Code
The for loop repeats codes within itself for a fixed number of times determined by the specified expression.
00:00
def load_input(input_str):
try:
x = int(input(input_str))
if x<5 or x>20:
raise ValueError
else:
return x
except ValueError:
print("Enter whole number between 5 to 20!")
raise
upperBound = load_input('Input the value of upper bound: ')
for a in range(1,upperBound-1):
for b in range(a+1, upperBound):
for c in range(b+1, upperBound+1):
if a*a + b*b == c*c:
print("({a}, {b}, {c}) is a Pythagorean Triple".format(a=a,b=b,c=c))
A variable stores a value that can be referred to or modified later in the program. A name, output, is assigned to the variable as an identifier in this case.