Attachment 'randd.py'

Download

   1 #!/usr/bin/python
   2 # -*- coding: utf-8 -*-
   3 
   4 '''Насколько randint() случайна?
   5 Посчитать количество одинаковых чисел в 1000000 результатов randint(1,100)'''
   6 
   7 import random
   8 
   9 # заведём список на 100 элементов
  10 Tab=100*[0]
  11 for n in xrange(1000000):
  12   s=random.randint(1,100)
  13   # увеличим счётчик
  14   Tab[s-1]+=1
  15 
  16 print Tab

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.