Python Learning Diary of three variables 2, logical judgment, for loop

Source: Internet
Author: User

Review the small code of the number of dictation, the problem arises.

The condition under the while statement. Should be Result==false and Answer=input (). If Answer=input () is written outside the while, it will output too small as it did yesterday.

There is the IF statement, syntax error, Baidu a bit, looks indented, in fact, is not indented.

1, the variable name rule: must be the letter or underscore _, and then can be letters, underscores or letters. Note case, uppercase A and lowercase a are different.

2, variables can be used to assign value a=1, can also be used to store data, such as the beginning of the mini-game num=10 preset. Used to compare sizes. To perform the operation.

Do the 1 to 100 cumulative. Think for a long time, and then only on Baidu check. Then I found that I was writing something so strange. Completely wrong, the brain can't turn.

Baidu After, originally I always want to use a formula b=xxxx to do accumulation, forget as long as a change, then B accumulated good value will change. So I should use a variable to store the previous well-changed value. Be sure to write on the outside of the while statement without participating in the loop. So the next time the loop is over, B takes the value directly from the outside of the newly changed number. (I'm probably the only one who can read my understanding notes ...) )

2. Logical Judgment

True or false, hair dizzy.

Did the "Crossin of the programming classroom," the 11th lesson (Getting started I followed this introductory tutorial to walk) left to right for the title, the right answer, my answer

Review sixth lesson The logical operation that produces a bool value is not, with and, or, since A is true, then not a is not true,b=not a, so false

Not B, negative negative meaning it (wry smile) false false=true

A and B are true and (with) False, must be two true

Ibid. 1<2 to False,b is also false, so false

3, for Loop, for a (variable name) in range (x,y-1) value range

Used to modify the 1 to 100 cumulative calculation of while

At first, it was silly not to assign a value.

After the change

That's it for today. Remember a few small points of knowledge first day. Start slowly.

Python Learning Diary of three variables 2, logical judgment, for loop

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.