Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python random choices weights

import random

numberList = [111, 222, 333, 444, 555]
print(random.choices(numberList, weights=(10, 20, 30, 40, 50), k=5))
# Output [555, 222, 555, 222, 555]
Comment

PREVIOUS NEXT
Code Example
Python :: %d%m%Y python 
Python :: Add two numbers as a linked list 
Python :: delete item from list python 
Python :: session has key python 3 
Python :: re.search() python 
Python :: python portfolio projects 
Python :: Converting (YYYY-MM-DD-HH:MM:SS) date time 
Python :: Python NumPy asarray Function Syntax 
Python :: why wont my python input accept string inputs 
Python :: python program to find sum of natural numbers using recursion 
Python :: abs in python 3 
Python :: seaborn and matplotlib python 
Python :: how to make a grid in python 
Python :: pandas fillna 
Python :: merge dataframe using pandas 
Python :: convert df.isnull().sum() to dataframe 
Python :: python how to replace a string in a list 
Python :: how to drop columns from pandas dataframe 
Python :: proper pagination django template 
Python :: how to extract dictionary value from string in python 
Python :: Python NumPy append Function Syntax 
Python :: zip lists 
Python :: change date format to yyyy mm dd in django template datepicker 
Python :: IndexError: invalid index to scalar variable. 
Python :: perform zero crossing using openCV 
Python :: complete dates pandas 
Python :: import pycocotools._mask as _mask error Expected 80, got 88 
Python :: how to convert frame number in seconds python 
Python :: python vars 
Python :: create contract from interface in brownie 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =