Actually very simple | Python code to find bugs (12)

**Python code to find bugs (12) **

**Code design requirements of the previous period: **

Generate a random number between 10 and 20.

code show as below:

Please read the code carefully to find out the bugs!

**Correct answer: There are 2 questions. **

(1) Random is a module in the Python3 standard library. When quoting, you only need to directly use the import keyword to import it. If the from keyword is used, it should be used in conjunction with import.

(2) Another error is the use of random seed() function. The seed() function does not return a random number, but determines whether the seed of the random number is fixed. The random.uniform(a,b) function should be used to generate random numbers in the specified interval, where a and b are the lower and upper limits of the interval.

So, the correct code should look like this:

**Comments: **

(1) Consolidate the usage of module import.

(2) Familiar with and understand the basic methods of creating random numbers.

(3) The questions in this issue seem simple, but they are actually very important. ‍ Especially with regard to the random number generation method, the usage of the random module in Python not only includes how to generate random numbers in a specified interval, but also generates random integers, random decimals, and generates the same or different random numbers multiple times in the same interval Functions and methods of counting. It is recommended that interested students study it in depth and incorporate this knowledge point into their knowledge base.

Recommended Posts

Actually very simple | Python code to find bugs (12)
Python code to find bugs (2)
Python code to find bugs(7)
Python code to find bugs(4)
Python code to find bugs (3)
Python code to find bugs(9)
Python code to find bugs(6)
Python code to find bugs (1)
Python code to find bugs(8)
Python code to find bugs(5)
Minimalism is the soul of Python | Python code to find bugs (10)
How to comment python code
python how to view webpage code
Centos7 installation is actually very simple
How to wrap in python code
Python handles operation code to execl
200 lines of Python code to achieve snake
Python Romberg method to find integral examples
Does Python code need to be indented
How to use code running assistant in python
500 lines of python code to achieve aircraft war
How to set code auto prompt in python
Python how to move the code collectively right
01. Introduction to Python
Introduction to Python