jackfrued / jackfrued/Python-100-Days
Day7 的练习6 杨辉三角,在下做了一点拙劣的改进
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 187k
- Forks
- 55.8k
- PR merge metrics
- No merged PRs in 30d
Description
原代码的三角每行前端是对齐的,改进了一下可以显示出标准三角的形状,代码很拙劣,仅供大家参考:
`def main():
num = int(input('Number of rows: '))
yh = [[]] * num
for row in range(len(yh)):
yh[row] = [None] * (row + 1)
print(' \t' *(((len(yh)-1-row))//2), end = '')
for col in range(len(yh[row])):
if row % 2 == 1:
print(' ', end = '')
if col == 0 or col == row:
yh[row][col] = 1
else:
yh[row][col] = yh[row - 1][col] + yh[row - 1][col - 1]
print(yh[row][col], end='\t')
print()
if name == 'main':
main()`
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the Day 7 exercise 6 materials and compare the existing Pascal triangle output with the example shown in this issue. Verify that the exercise displays a standard centered triangle while preserving the expected values, then run the exercise to confirm the output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- content
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100