Example introduction to Python2 random number sequence generator

巴扎黑
Release: 2017-09-05 11:35:53
Original
1586 people have browsed it

This article mainly introduces the Python2 random number sequence generator, and analyzes the related implementation skills of Python based on the random module to operate random numbers in the form of simple examples. Friends in need can refer to the following

The examples of this article describe Python2 Random number sequence generator. Share it with everyone for your reference, the details are as follows:


#filename:randNumber.py
import random
while True:
  try:
    row=int(raw_input('Enter the rows:'))
    cols=int(raw_input('then Enter the cols:'))
    minNum=int(raw_input('then Enter the minNumber:'))
    maxNum=int(raw_input('then Enter the maxNumber:'))
    r=0
    while r<row:
      line=&#39;&#39;
      c=0
      while c<cols:
        s=random.randint(minNum,maxNum)
        line+=str(s)
        line+=&#39;  &#39;
        c+=1
      r+=1
      print(line)
  except ValueError as err:
    print err
Copy after login

The above is the detailed content of Example introduction to Python2 random number sequence generator. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!