.png)
VARIABLES AND SOME ARITHMETIC
Problem:
Given: Two positive integers a and b, each less than 1000.
​
Return: The integer corresponding to the square of the hypotenuse of the right triangle whose legs have lengths a and b.
​
Sample Dataset: 4 5
​
Sample Output: 41
Solution:
You need to find out the square of the hypotenuse when a and b are sides of a right angled triangle. Rings a bell, doesn't it? Ah, we need to use Pythagoras's trusty theorem:
c = a + b
2 2 2
c
b
a
To find the value of c squared we need to get the sum of a squared and b squared:
< >
a = 4
b = 5
​
c_squared = a**2 + b**2
print(c_squared)
Output:
41
That seems right!
​
Copy and paste the integer you get from running your code on the sample data onto the Rosalind answer terminal and submit. Annnd get yourself a cookie!