Stupid way to learn Python (27)

Source: Internet
Author: User
Tags true true

Exercise 27: Remembering logical relationships

So far you've learned to read and write files, command-line processing, and many Python math functions. Today, you are going to start learning logic. What you want to learn is not the advanced logic theory of the Institute, but the basic logic knowledge that programmers use every day to get the program running.

You need to remember something before you learn logic. This exercise I ask you to complete one weeks, do not modify the schedule without authorization, even if you are very annoying, you have to persist. This exercise will let you recite a series of logic tables, which will make it easier for you to complete the following exercises.

What you need to warn you about is this: It starts off with a bit of fun, and you start to think it's boring, but it's designed to teach you a key skill that a programmer must have--some important concepts that must be remembered, and once you understand these concepts, you get a pretty good sense of accomplishment, But in the beginning you will find them difficult to master, as with the squid wrestling, and wait until one day, you will brush the enlightened. You will get a great return from these basic memory learning.

Here's a way to remember something and not to freak yourself out: In a whole day, remember a small part of your memory and mark up the parts you need to strengthen. Don't try to recite it in two hours, it's not going to be a good result. No matter how long you spend, your brain will only keep what you've seen in the first 15 or 30 minutes.

Instead, what you need to do is create some index cards with two columns of content, write the logical relationship on the front, and write the answer on the opposite side. The result you need to do is: Take out a card and see the positive expression, such as "True or False", you can immediately say the result is "true"! Keep practicing until you can do it.

Once you can do this, you need to write a truth table in your notebook every night. Don't just copy them, try to memorize the truth-table, if you find out where not to remember, quickly skim the answer here. This will train your brain to let it remember the whole truth table.

Don't spend more than a week on this, because you'll continue to learn them as you go through the application process later.

Logical terminology

In Python we use the following terms (characters or words) to define the true (TRUE) or False (false) of things. The logic of a computer is to check that the characters or combinations of variables in the program are in the same place. The result of the expression is true.

    • and and
    • or OR
    • not non-
    • != (not equal) is not equal to
    • == (equal) equals
    • >= (greater-than-equal) greater than or equal to
    • <= (less-than-equal) less than or equal to
    • True True
    • False false

You've actually seen these characters, but you may not have seen them. These words (and, or, not) are the same as the effect you expect, exactly as they are in English.

Truth table

We will use these characters to create the truth table you need to remember.

not
True?
Not False True
Not True False
OR True?
True or False True
True or True True
False or True True
False or False False
Td>false
and true?
True and false False
True and true true
False and True
false and False false
not OR true?
not (True or False) False
not (true or True) False
not (false or True) false
not (false or false) True
not and true?
not (true and False) true
not (true and true) False
not (False and True) true
not (false and false) True
!= true?
1! = 0 True
1! = 1 False
0! = 1 True
0! = 0 False
== True?
1 = = 0 False
1 = = 1 True
0 = = 1 False
0 = = 0 True

Now use these tables to create your own cards and take one weeks to memorize them slowly. Remember, this book will not require you to succeed or fail, as long as you try to learn every day, on the basis of trying to spend a little more effort on it.

Stupid way to learn Python (27)

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.