selfteaching / selfteaching/selfteaching-python-camp

Day04 作业乘法表 关于range()的问题

Open
#1,014 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
151
Forks
875
PR merge metrics
No merged PRs in 30d

Description

day4作业乘法表,我的代码:

for i in range(1,10): 
#for i in range(0,10): #如果这一行改成for i in range(0,10),结果是一样的
    for j in range(1,i+1): 
         print(i,'*',j,'=',i*j,end='   ')
         if i == j: 
            print()

如果把第一个i变量的range(1,10)改成range(0,10),输出结果竟然是一样的,i变量依然是从1-9变化。
是因为如果i是0的时候,j的range(1,i+1)是个空集导致输出结果上看不出来吗?
谁能帮我具体解释一下呢?谢谢!
@oneMoreTime1357

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

Start with the Python snippet in the issue and compare the loop behavior for range(1, 10) and range(0, 10). Read the Python range documentation and verify the nested loop's behavior when i is 0; the issue is resolved when the explanation clearly accounts for the identical output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
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.