GoConqr has a new look! Let us know what you think.

Module 6 of 11 · Text

Solving simple mathematical problems

David Khieu

Solving simple mathematical problems

Now you should be able to construct a short program solving simple mathematical problems such as the Pythagorean theorem: 

The square of the hypotenuse is equal to the sum of the squares of the other two sides.

The following code evaluates the length of the hypotenuse (i.e., the longest side of a right-angled triangle, the one opposite of the right angle) using the Pythagorean theorem:

a = 3.0

b = 4.0

c = (a ** 2 + b ** 2) ** 0.5

print("c =", c)

Note: we need to make use of the ** operator to evaluate the square root as:

√ (x)  = x(½)

and

c = √ a2 + b2 

Can you guess the output of the code? 

Check below and run the code in the editor to confirm your predictions.

c = 5.0

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?