Python learning diary 3 variable 2, logical judgment, for loop, python variable
Review the questions that occur when you write a quiz code.
The condition in the While statement. It should be when result = false and answer = input. If answer = input () is written outside the while clause, too small will be output as it was yesterday.
There is also the if statement. The syntax is incorrect. Baidu seems to be indented, but it is not indented.
1. Naming rules for variables: The name must start with a letter or underscore _, followed by a letter, underscore, or letter. Note that uppercase letters A and lowercase letters a are different.
2. variables can be used to assign a value to a = 1 or store data. For example, the preset num = 10 at the beginning of a game. Used to compare the size. .
Do the accumulation of 1 to 100. After thinking for a long time, I can only check it for hundreds of times. Then I found that I was writing such a strange thing. Completely wrong. I cannot bend my mind
After Baidu, I always wanted to use the formula B = xxxx to accumulate data. I forgot that if a changes, then the accumulated value of B also changes. So I should use variables to store the previous value that is better. It must be written outside the while statement and not involved in the loop. Then, in the next loop, B directly takes the value of the variable number from the outside. (Maybe only I can understand my comprehension notes ...)
2. logical judgment
Fake and fake, hair dizzy.
I made a question in class 11th in the Crossin programming classroom (I followed this tutorial for getting started). The question is left to right. The correct answer is my answer.
Review the logic operation that generates the bool value in Lesson 6. It is not, and, or. Since a is true, not a is not true, B = not a, so false.
Not B, just make a positive impression (SMILE) false = true
A and B is true and (and) false. It must be true for both of them.
Same as 1 <2 is false, B is false, so false
3. for Loop, for a (variable name) in range (x, Y-1) value range
Used to modify the accumulate calculation from 1 to 100 of while
At the beginning, I was dumbly not to assign a value.
After modification
That's it today. Remember a few tips a day. Start.