Home >Backend Development >Python Tutorial >Example introduction to Python2 random number sequence generator

Example introduction to Python2 random number sequence generator

巴扎黑
巴扎黑Original
2017-09-05 11:35:531616browse

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

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!

Statement:
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