jackfrued / jackfrued/Python-100-Days

day3练习有误-输入三条边长,如果能构成三角形就计算周长和面积

Open
#582 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
187k
Forks
55.8k
PR merge metrics
No merged PRs in 30d

Description

练习3:输入三条边长,如果能构成三角形就计算周长和面积。
原代码:
"""
判断输入的边长能否构成三角形,如果能则计算出三角形的周长和面积

Version: 0.1
Author: 骆昊
"""
a = float(input('a = '))
b = float(input('b = '))
c = float(input('c = '))
if a + b > c and a + c > b and b + c > a:
print('周长: %f' % (a + b + c))
p = (a + b + c) / 2
area = (p * (p - a) * (p - b) * (p - c)) ** 0.5
print('面积: %f' % (area))
else:
print('不能构成三角形')

除了考虑两边之和大于第三边,也要考虑,两边之差小于第三边

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search the repository for the exercise 3 Python snippet included in the issue and inspect its triangle-validation condition. Update the exercise to reflect the requested validity rules, then run it with valid and invalid side lengths and confirm the appropriate perimeter, area, or rejection output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.