<center> [image source](https://i0.wp.com/www.mathbootcamps.com/wp-content/uploads/the-pythagorean-formula.png?resize=560%2C315)</center> <center>*In a right-angled triangle: the square of the hypotenuse is equal to the sum of the squares of the other two sides.*</center> #### What Will I Learn? This tutorial aims to: - Solve one side of a right-angled triangle using Pythagorean Theorem in Python #### Requirements - Python IDLE #### Difficulty - Basic #### Tutorial Contents ##### The Code: First, we import sqrt function from math module into the current namespace. <code>from math import sqrt</code> Display an information about the program (may not be included). <code>print('This is a Pythagorean Theorem calculator! Calculate one side of right-angled triangle.') print('Assume the sides are a, b, c and c is the hypotenuse.')</code> Second, ask the user on which side to calculate and assign it to a variable (i used variable 'choice'). <code>choice = input('Which side (a, b, c) do you want to calculate? side: ')</code> Third, making if ... elseif condition statement. If the user wants to find for the hypotenuse which is side c. <code>if choice == 'c': a = float(input('Input the length of side a: ')) b = float(input('Input the length of side b: '))</code> Solving for the c with the formula: √a^2+b^2 <code>c = sqrt(a * a + b * b)</code> Display the value of side c <code>print('The length of side c is %g: ' %(c))</code> Else if, the user wants to find for the side b. <code>elif choice == 'b': a = float(input('Input the length of side a: ')) c = float(input('Input the length of side c: '))</code> Solving for the b with the formula: √c^2-a^2 <code>b = sqrt(c * c - a * a)</code> Display the value of side b <code>print('The length of side b is %g: ' %(b))</code> Else if, the user wants to find for the side a. <code>elif choice == 'a': b = float(input('Input the length of side b: ')) c = float(input('Input the length of side c: '))</code> Solving for the a with the formula: √c^2-b^2 <code>a = sqrt((c * c) - (b * b))</code> Display the value of side a <code>print('The length of side a is %g: ' %(a))</code> Lastly, if the input is invalid. <code>else: print('Invalid Input!')</code> #### Curriculum Please visit my previous tutorials: - [Solving Quadratic Equation in easiest way using Python](https://steemit.com/utopian-io/@kimp0gi/solving-quadratic-equation-in-easiest-way-using-python) <center>Thanks for reading! Hope you learn something.</center> --- <br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@kimp0gi/solving-one-side-of-right-angled-triangle-using-pythagorean-theorem-in-python">Utopian.io - Rewarding Open Source Contributors</a></em><hr/>
author | kimp0gi | ||||||
---|---|---|---|---|---|---|---|
permlink | solving-one-side-of-right-angled-triangle-using-pythagorean-theorem-in-python | ||||||
category | utopian-io | ||||||
json_metadata | {"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":102230800,"name":"Pythagoras_theorem","full_name":"khushalimehta/Pythagoras_theorem","html_url":"https://github.com/khushalimehta/Pythagoras_theorem","fork":false,"owner":{"login":"khushalimehta"}},"pullRequests":[],"platform":"github","type":"tutorials","tags":["utopian-io","steemit-engineering","programming","cebu","philippines"],"users":["kimp0gi"],"links":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1516018374/bymisl5pbx98zgf1waq6.png","https://i0.wp.com/www.mathbootcamps.com/wp-content/uploads/the-pythagorean-formula.png?resize=560%2C315","https://steemit.com/utopian-io/@kimp0gi/solving-quadratic-equation-in-easiest-way-using-python"],"image":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1516018374/bymisl5pbx98zgf1waq6.png"],"moderator":{"account":"scipio","time":"2018-01-16T13:36:54.847Z","flagged":true,"reviewed":false,"pending":false}} | ||||||
created | 2018-01-15 13:48:12 | ||||||
last_update | 2018-01-16 13:36:54 | ||||||
depth | 0 | ||||||
children | 3 | ||||||
last_payout | 2018-01-22 13:48:12 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 0.106 HBD | ||||||
curator_payout_value | 0.019 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 2,868 | ||||||
author_reputation | 3,215,145,789,728 | ||||||
root_title | "Solving one side of right-angled triangle using Pythagorean Theorem in Python" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 29,706,973 | ||||||
net_rshares | 17,381,824,828 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
geke | 0 | 8,695,426,896 | 10% | ||
jassennessaj | 0 | 68,980,836 | 5% | ||
ted7 | 0 | 3,612,128,586 | 100% | ||
jamescash | 0 | 364,186,231 | 100% | ||
steemph.cebu | 0 | 2,752,854,499 | 5% | ||
ybanezscarlet | 0 | 398,915,108 | 100% | ||
imkareencajes | 0 | 361,940,394 | 100% | ||
jbeguna04 | 0 | 580,655,279 | 100% | ||
kimp0gi | 0 | 546,736,999 | 100% |
Your contribution cannot be approved because it is not as informative as other contributions. See the [Utopian Rules](https://utopian.io/rules). Contributions need to be informative and descriptive in order to help readers and developers understand them. Explanation: - the [GitHub repo](https://github.com/khushalimehta/Pythagoras_theorem/blob/master/Pythagoram%20Theorem.py) you linked to, is 9 months old, probably is written by somebody else, and does the exact same thing as you are trying to teach. (Only your code is less elegant). I won't call it "plagiarism" but it's not original either! - your tutorial doesn't provide the full Python3 script, - if you want to contribute more Python3 tutorials - you're welcome!- but at least then try to explain in a step-by-step fashion how the Python 3 language works, or explain how to implement / use a certain module (included in the standard lib, or external), but **do not** publish tutorials for very trivial examples: now you picked the Pythagorean Theorem (c^2 = a^2 + b^2), and I don't think any serious Python developer is interested in a tutorial to solve that Theorem, - but any beginner Pythonista **is interested** in good tutorials explaining **language and/or module concepts**. Good luck on your next Python3 tutorial! You can contact us on [Discord](https://discord.gg/uTyJkNm). **[[utopian-moderator]](https://utopian.io/moderators)**
author | scipio |
---|---|
permlink | re-kimp0gi-solving-one-side-of-right-angled-triangle-using-pythagorean-theorem-in-python-20180116t134334838z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-01-16 13:43:36 |
last_update | 2018-01-16 13:43:36 |
depth | 1 |
children | 2 |
last_payout | 2018-01-23 13:43:36 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 1.396 HBD |
curator_payout_value | 0.460 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,404 |
author_reputation | 34,229,822,336,032 |
root_title | "Solving one side of right-angled triangle using Pythagorean Theorem in Python" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 29,943,086 |
net_rshares | 197,385,340,209 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
utopian.tip | 0 | 197,385,340,209 | 17.46% |
thank you sir
author | kimp0gi |
---|---|
permlink | re-scipio-re-kimp0gi-solving-one-side-of-right-angled-triangle-using-pythagorean-theorem-in-python-20180116t134939228z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-01-16 13:49:36 |
last_update | 2018-01-16 13:49:36 |
depth | 2 |
children | 0 |
last_payout | 2018-01-23 13:49:36 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 13 |
author_reputation | 3,215,145,789,728 |
root_title | "Solving one side of right-angled triangle using Pythagorean Theorem in Python" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 29,944,310 |
net_rshares | 0 |
Hey @scipio, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!
author | utopian.tip |
---|---|
permlink | re-re-kimp0gi-solving-one-side-of-right-angled-triangle-using-pythagorean-theorem-in-python-20180116t134334838z-20180116t155524 |
category | utopian-io |
json_metadata | "" |
created | 2018-01-16 15:55:24 |
last_update | 2018-01-16 15:55:24 |
depth | 2 |
children | 0 |
last_payout | 2018-01-23 15:55:24 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 156 |
author_reputation | 238,310,597,885 |
root_title | "Solving one side of right-angled triangle using Pythagorean Theorem in Python" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 29,970,721 |
net_rshares | 0 |