Bool, if, while, randint, boolrandint

Source: Internet
Author: User

Bool, if, while, randint, boolrandint

1. bool Value

This seems understandable. There are comparison operators, and logical operators all generate bool values. First, let's look at these. This is true or false in Middle School Mathematics questions (think of the pain of mathematics ).

There is an int function. Baidu's explanation is rounded up. Do not deliberately understand, for fear of getting into a dead end.

2. if

When we see whether it is true or false or if, it is really a problem of a mathematical problem. Note that you always write numbers directly instead of the variable name. Num = 10. It should be num. The reason for the running error is that the English state is not added after the if statement: after it is added, it is OK. You're a fucking genius.

 

 

 

3. while

Are you sure you want to lose? The original equal sign = is mixed with the value =. Syntax error, invalid syntax. When the while statement is followed by the if statement:

 

It seems that you really need to be careful when learning this... Although an error is reported, the English language is too watery. Answer is not defined when the problem occurs in Row 6. After reading the example, I didn't assign a value to answer, that is, I couldn't know what answer is in these statements. If answer> num, what is greater than 10? This is the cause of the error. Remember to assign the value =, equal to =

After the change, as long as bingo = False, the loop will continue and end. As long as the bingo value is changed to another value after the correct statement, the loop ends.

Also, if and while must be indented. But I used pycharm, which automatically indented me.

4. randint

First, remember the from Module name import method name. from random import randint can be used to generate random numbers.

Details! If a punctuation mark is incorrect, it cannot be used. I forgot what went wrong after the change.

 

 

It turns out that answer = input () is placed outside the while loop, so it is always in the large condition of bingo = False and answer = input. Always output too small.

That's it today.

 

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.