Home > database >  Python perfect number
Python perfect number

Time:09-21

Small white consult:
Q1:
Start from 1 x,
If
For y in range (1, x) :
Break
Print (y)
Why will get 1


CodePudding user response:

Conditions lead to a final judgment, if x==s: will perform a print, only x is equal to 1 are equal

CodePudding user response:

reference 1st floor m0_46392195 response:
conditions lead to a final judgment, if x==s: will perform a print, is only equal to x is equal to 1

If the rewriting a piece of code
For x in the range (1100, 00) :
S=0
For I in range (1, x) :
Break
Print (y)
Why get 1
The [1, 1) why the output is 1


CodePudding user response:

You have a problem to rewrite the code

CodePudding user response:

reference m0_46392195 reply: 3/f
you have a problem to rewrite the code

I'm sorry??
Is the output of 1
For the x in the range (1100) :
For I in range (1, x) :
Break
print(i)

CodePudding user response:

First you finally the break out of the question, out of all the cycle, only to I=1, so I can only equal to 1

CodePudding user response:

For the x in the range (1100) :
For I in range (1, x) :
Print (I)

CodePudding user response:

reference 4 floor qq_46399291 response:
Quote: reference m0_46392195 reply: 3/f
you have a problem to rewrite the code

I'm sorry?
Is the output of 1
For the x in the range (1100) :
For I in range (1, x) :
Break
Print (I)

Circulation to the second floor for the first time I throughout the code is over there, I value the last and the range of (1, x) the result of the assignment, to put it bluntly that code
  • Related