In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about how to find the triangle area in Python. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
1. Open the editor IDLE that comes with python. Enter the code and the interface is as follows
2. The running result is shown below.
Second, code analysis
If it is known that the triangles are on three sides a, b and c, then:
(Helen's formula) s = (a+b+c) / 2
Triangle area = sqrt [s (smura) (smaeb) (smaec)]. Because * * stands for power operation in python, the open root sign can be expressed as s (smaeb) (sMub) (sMuc) * *.
# calculated area
Area = (s* (smura) * (smurb) * (smurc)) * * 0.5
Finally, the output is in the format of% 0.2f, that is, a floating point number that retains 2 decimal places.
Print ('triangle area% 0.2f'% area)
III. Summary
In the python language, there is basically not much redundant code, unlike the C language or Java language has a lot of difficult to understand symbols, which is the advantage of python. Basically, the mathematical formula can be run directly, so it is very fast to learn. In the following chapters, it will slowly increase the difficulty. I wish you all to improve step by step!
Python features:
Python is not only an object-oriented and interpretive scripting language, but also a universal language with powerful and perfect functions. Compared to other programming languages (such as Java), Python code is very simple and easy to use.
Python can easily accomplish everything from string processing to complex 3D graphics programming with the help of extension modules.
The expansibility of Python is reflected in its modules. Python has the richest and most powerful class libraries in scripting languages, which cover most application scenarios such as file IBO, GUI, network programming, database access, text manipulation and so on.
One of the best examples of Python extensibility is that when we need a key piece of code to run faster, we can write it in C or C++, and then use it in Python programs.
The above is how to find the triangle area in the Python shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.