Python3 calculates the area code of the triangle

  • 2020-06-15 09:46:06
  • OfStack

Opinions vary on Python, but there are only two languages, powerful and trashy. Most people are still positive about Python and think it is strong. A few days ago, I chatted with two college classmates. One was doing a mobile phone test, and the other was doing maintenance work for the banking system. Both of them were in Beijing. Both of them worked and studied at the same time, and one of them studied Python. I can't afford to be left behind. I'm on the path of Python. I personally think for the majority of programming fans, especially college students, you can have time to learn a language, for the future is very helpful.

The following example is to calculate the area of a 3-angle shape by inputting the length of the 3-side by the user:


# -*- coding: UTF-8 -*-

# Filename : test.py
# author by : www.w3cschool.cn

a = float(input(' The input 3 Angle of the first 1 Side length : '))
b = float(input(' The input 3 Angle of the first 2 Side length : '))
c = float(input(' The input 3 Angle of the first 3 Side length : '))

#  Calculate half perimeter 
s = (a + b + c) / 2

#  Calculating area 
area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
print('3 The angular area is  %0.2f' %area)

The output result of executing the above code is:


$ python test.py 
 The input 3 Angle of the first 1 Side length : 5
 The input 3 Angle of the first 2 Side length : 6
 The input 3 Angle of the first 3 Side length : 7
3 The angular area is  14.70

conclusion

The above is the entire content of Python3 calculation area code of 3 angles, I hope to be helpful to you. Interested friends can continue to refer to other related topics in this site, if there is any deficiency, welcome to comment out. Thank you for your support!


Related articles: