In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "how to solve the third side length of the triangle by python". The editor shows you the operation process through the actual case. The operation method is simple, fast and practical. I hope this article "how to solve the third side length of the triangle by python" can help you solve the problem.
Solve the import mathx=input of the third side of the triangle ('enter the length of both sides and the angle between them (degrees):') # use a space to separate three values. The split () method is used to segment the string c=math.sqrt (a**2+b**2-2*a*b*math.cos (theta*math.pi/180)) # cos () and the parameter is Radian print ('centering theta*math.pi/180 c).
Run screenshot
Usage of python trigonometric function
Trigonometric functions in python generally include:
Function description sin (x) returns the sine value of x radians cos (x) returns the cosine value of x radians tan (x) returns the tangent value of x radians asin (x) returns the arc value of x acos (x) returns the inverse cosine arc value of x atan (x) returns the arc value of x
The parameters of the above trigonometric function are: radians! It's not an angle!
In mathematics and physics, radians are the unit of measurement of angles.
It is a unit derived from the international unit, with the abbreviation rad. Definition: an arc whose length is equal to the radius and whose center angle is 1 degree.
360 °= 2 π radians, so 1 Radian is about 57.3 °, that is, 57 °17 °44.806 ".
1 °= π / 180 radians
180 °= π radians
(in python, pi = π, which is a mathematical constant, don't forget to quote math!)
When using trigonometric functions in python, you can't use them directly, you have to import the math module first.
As follows:
Import matha = math.cos (math.pi) # find cos (180 °) b = math.sin (math.pi/2) # find sin (90 °) print (AMO b) "output:-1.0"
In addition, there are two functions in the math module:
Degrees (x): converts radians to angles.
Radians (x): converts the angle to radians.
As follows:
Import matha = math.degrees (math.pi/2) print (a) b = math.radians (180) print (b) "" output: 90.03.141592653589793180 degrees is π. " This is the end of the introduction to "how to solve the third side length of a triangle by python". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.