76, Python study the second article

Source: Internet
Author: User

Generate test data for random numbers

" "Created on April 8, 2017 @author:weizhen#to Create data for testing" "ImportRandom fromNumPyImportMaximumdefget_int (msg, minimum, default): whileTrue:Try: Line=input (msg)if  notLine andDefault is  notNone:returnDefault I=Int (line)ifI <Minimum:Print("must be >=", minimum)Else:                returnIexceptValueError as err:Print(ERR) rows= Get_int ("rows:", 1, None) columns= Get_int ("Columns", 1, None) Minimum= Get_int ("minimum (or Enter for 0):",-1000000, 0) default= 1000ifDefault <Minimum:default= 2 *Minimummaximum= Get_int ("maximum (or Enter for"+ STR (default) +"):", minimum, default) row=0 whileRow <Rows:line=""column=0 whileColumn <columns:i=random.randint (minimum, maximum) s=Str (i) whileLen (s) < 10: S=" "+s Line+=s Column+ = 1Print(line) row+ = 1

The results of the above program run are as follows:

76, Python study the second article

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.