Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python random choice from list

import random
list = [20, 30, 40, 50 ,60, 70, 80]
sampling = random.choices(list, k=4)      # Choices with repetition
sampling = random.sample(list, k=4)       # Choices without repetition
Comment

python random choice in list

import random

my_list = ["a", "b", "c", "d"]
random_from_list = random.choice(my_list)
Comment

PREVIOUS NEXT
Code Example
Python :: pickle save 
Python :: python program for simple interest 
Python :: python list contains substring 
Python :: how to tell python to create a random numer 
Python :: matplotlib plot 
Python :: plotly express lineplot 
Python :: how to move mouse with pyautogui 
Python :: change name of column pandas 
Python :: how to input multiple integers in python 
Python :: python parse dict from string 
Python :: copy file in python3 
Python :: how to find the length of a list in scratch 
Python :: insert QlineEdit into QMenu python 
Python :: `12` print () 
Python :: fig title python 
Python :: firefox selenium python 
Python :: how to convert index to column in pandas 
Python :: convert tibble to dataframe 
Python :: koncemzem 
Python :: pandas drop extension name from list of files 
Python :: Fill NaN of a column with values from another column 
Python :: default style matplotlib python 
Python :: how to create text file with python and store a dictionary 
Python :: python locks 
Python :: rename coordinate netcdf python xarray 
Python :: how many data types are specified to numeric values in python 
Python :: save video cv2 
Python :: rearrange list python 
Python :: json post python with headers 
Python :: urllib.error.HTTPError: HTTP Error 403: Forbidden 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =